There are two things that have escaped your notice:
- A moved-from object will still be destructed, so your move operation must transfer resources
- When a
vector
grows, it might need to re-allocate which is a 4 steps operations: acquire new storage, move-construct (or copy-construct) new elements in the new storage (from the old), destroy old elements, release old storage.
So, your problem is simply that you do not transfer resources properly; using std::unique_ptr
as the basis of your custom class and you will not suffer such woes.