I want to make a container which manages big objects which performs deep copies on copy construction and copy assignment.
template <class TBigObject>
class Container : public std::vector< std::shared_ptr<TBigObject> >
{
public:
Container(int nToAllocate){ /* fill with default constructed TBigObjects */ }
Container(const Container& other){ /* deep copy */ }
Container(Container&&) = default;
Container& operator = (const Container& population){ /* deep copy */ }
Container& operator = (Container&&) = default;
};
I would like to know what do the defaulted:
Container(Container&&) = default;
Container& operator = (Container&&) = default;
members actually do.
If I call:
Container<int> makeContainer()
{
...
}
and set up debugging breakpoints at:
Container<int> moveAssigned;
moveAssigned = makeContainer(); // EDIT corrected thanks to Andy Prowl
Container<int> moveConstructed(makeContainer());
and inside the copy constructor and assignment operator, the debugger jumps over these breakpoints. So it seems that the defaulted move members actually do not perform deep copies and move all the subobjects.
Is this behavior guaranteed by the standard? Do defaulted move members behave intuitively and move all the subobjects?