samedi 21 février 2015

How to implement move constructor for large size non-pointer member?

On this website


http://ift.tt/1DF92YQ


there is an example of simple class with a move constructor. How would look like a move constructor of similar class:



class MemoryPage
{
std::vector<char> buff;

public:
explicit MemoryPage(int sz=512)
{
for(size_t i=0;i<sz;i++)
buff.push_back(i);
}

};


would it be



MemoryPage::MemoryPage(MemoryPage &&other)
{
this->buff = std::move(other.buff);
}


?


Aucun commentaire:

Enregistrer un commentaire