I just had an argument in codereview where it was pointed out that a class having a member std::shared_ptrwould break CopyConstructible , in particular:
The following expressions must be valid and have the indicated effects.
T u = v;
V value does not change
The reason was that copying would change the original object by increasing the reference count shared_ptr, but my counter argument is that the reference count is kept separate from shared_ptr. Changing the reference counter is a side effect, but the link does not indicate that side effects outside the copied object are prohibited.
But then I’m not a language lawyer, so I can be wrong.
What is correct according to the C ++ standard?
source
share