This is actually a design flaw in your CopiedClass that needs to be fixed.
std::vector behaves as expected and is documented.
From the little code you show
member->DoSomething();
this means that you are going to take a shallow copy of the pointer to what ever.
in our case, this is not necessarily the case. Currently, we may have some elements left in the vector, because we decided not to delete them, which are real objects, but their data does not guarantee correct behavior.
It so happened that the "member" is reset to zero when we are done with the original object and leave it in the vector, so when std :: vector tries to copy it, it will work.
Since your copy constructor does not correctly handle this situation regarding rule 3 rule, your CopiedClass design CopiedClass incorrect.
You should either create a deep copy of your member , or use a smart pointer (or a simple instance), rather than a raw pointer.
Smart pointers should take good care of the management for these members.
Also for the code snippet above, you should test against nullpointer before blindly dereferencing and calling DoSomething() .
Can std::vector be prevented from copying this element?
As you ask for C ++ 11, this is possible, but requires that you never change the size of the vector and provide a move constructor and assignment operator for CopiedClass .
Otherwise, std::vector explicitly requires types to copy (at least for certain operations):
T must satisfy CopyAssignable and CopyConstructible .
Follow these requirements correctly.
... he does this by copying the last element that he currently holds.
Also note: in a situation, you need to resize the vector, all existing elements will be copied, and not just the last one, as you assume.