My code snipper is:
my_string& operator=(my_string&& other)
{
if (this != &other)
{
if (buffer_ != nullptr)
{
delete[] buffer_;
}
size_ = std::move(other.size_);
buffer_ = std::move(other.buffer_);
//other.size_ = 0; // how to set a value?
}
return *this;
}
bool empty() const
{
return size_ == 0;
}
I want to set size_
for a moved-from object to empty
to work correctly.
If I uncomment line other.size_t = 0;
, then some internal errors happens.
Aucun commentaire:
Enregistrer un commentaire