ps-lite
ps-lite copied to clipboard
more standard implementation of SArray::operator=
It might be better to implement SArray::operator= in a more standard way.
1 template <typename W>
2 SArray<V>& operator=(const SArray<W>& 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<V>(arr.ptr(), reinterpret_cast<V *>(arr.data()));
9 }