STL like Vector,Pair, Map

David B. Held dheld at codelogicconsulting.com
Sun Nov 18 19:41:18 PST 2007


James Dennett wrote:
> [...]
> Plenty, though admittedly many containers are *not* copied
> so some code would port easily.  The pain would be in finding
> places where copy semantics were needed; the best way to do
> that would probably be to artificially disable copying in the
> C++ code and check where sharing would be viable.

Every STL container I know about gives you full-on value/copy semantics 
when you want it.  If I assign one map<> to another, there is no 
sharing.  Same for list<>, vector<>, deque<>, etc.  If you allow 
sharing, you are not offering value semantics (which is fine if that is 
what you are advertising).  The only time sharing is indistinguishably 
safe is for const containers.

Dave



More information about the Digitalmars-d mailing list