Designing a new system from scratch. I\'ll be using the STL to store lists and maps of certain long-live objects.
Question: Should I ensure my objects have copy co
If the objects are to be referred to elsewhere in the code, store in a vector of boost::shared_ptr. This ensures that pointers to the object will remain valid if you resize the vector.
Ie:
std::vector > protocols;
...
connection c(protocols[0].get()); // pointer to protocol stays valid even if resized
If noone else stores pointers to the objects, or the list doesn't grow and shrink, just store as plain-old objects:
std::vector protocols;
connection c(protocols[0]); // value-semantics, takes a copy of the protocol