Regarding to the requirement for C++ stl container element, the standard says: the element type should be CopyConstructible, and there is a table for CopyConstructible requirements. Also by various books (Josuttis, etc.), the generated copy should be “equivalent to” the source.
I think I need some clarity here. What is exactly “equivalent to”? Also I am a bit confused with the relation between the “CopyConstructible” and the “deep/shallow copy”. In general, a copy constructor is either shallow copy or deep copy. So which one applies to the “CopyConstructible”, and which does not?
Thanks for any comments!
Deep or shallow copy both work. For instance,
shared_ptralways does a shallow copy (with some extra reference counting stuff), and you can use them in containers just fine. It depends on the semantics of copy-operation.Equivalent means your program should not depend on whether it works with the original or with the copy.