Decision on container design

bearophile bearophileHUGS at lycos.com
Tue Feb 1 09:49:57 PST 2011


Andrei:

> A better solution is to define something like
> 
> auto c = new Classify!Container;
> 
> which transforms a value into a class object.
> 
> With this, the question becomes a matter of choosing the right default: 
> do we want values most of the time and occasional references, or vice 
> versa? I think most of the time you need references, as witnessed by the 
> many '&'s out there in code working on STL containers.

I agree that most times a reference is better. This brings back the need for a very good (efficient, syntactically readable, and even if not safe, able to spot most common errors, and RAII-safe) way to allocate class instances in-place, on the stack or inside another struct/class.

Bye,
bearophile


More information about the Digitalmars-d mailing list