more standard implementation of SArray::operator=
microwish opened this issue · comments
It might be better to implement SArray::operator= in a more standard way.
1 template
2 SArray& operator=(const SArray& arr)
3 {
4 if (this == &arr) return *this;
5 size_ = arr.size() * sizeof(W) / sizeof(V);
6 CHECK_EQ(size_ * sizeof(V), arr.size() * sizeof(W));
7 capacity_ = arr.capacity() * sizeof(W) / sizeof(V);
8 ptr_ = std::shared_ptr(arr.ptr(), reinterpret_cast<V *>(arr.data()));
9 }