I wrote a class which contains move constructor and move assignment operator. I want to know where and how these move semantics are used in application?
class Base
{
public:
Base():iptr(new int(10)){}
~Base(){}
Base(const Base& b):iptr(new int(*b.iptr))
{
cout << "Copy ctor" << endl;
}
Base& operator=(const Base& b)
{
iptr.reset(new int(*b.iptr));
}
//move ctor
Base(Base&& b)
{
cout << "Move ctor" << endl;
iptr = std::move(b.iptr);
}
//move assign op
Base& operator=(Base&& b)
{
cout << "Move assign op" << endl;
iptr = std::move(b.iptr);
return *this;
}
void printVal(){cout << *iptr << endl;}
private:
std::unique_ptr<int> iptr;
};