container stuff

Michel Fortin michel.fortin at michelf.com
Wed May 26 11:28:06 PDT 2010


On 2010-05-25 19:18:43 -0400, bearophile <bearophileHUGS at lycos.com> said:

> Andrei Alexandrescu:
> 
>> any container must be a reference type, whether implemented as a class 
>> or struct.<
> 
> This probably makes their usage simpler, so this can be the right 
> decision. But then you can't define something like a TinyHashSet or a 
> StaticBitSet that are better allocated on the stack...

Well, in a way I think you can, but you have to stretch the definition 
a bit. A value-type container you can move but can't copy (because you 
used "@disable this(this)") is semantically indistinguishable to a 
reference-type container with a unique non-copiable (but moveable) 
reference. The only problem is that most algorithms probably won't work 
with such a thing, they'll expect a copy of the reference right in 
their function arguments.

This does bother me a little. That it allows statically allocated 
collections is something I like a lot of the C++ container model.


-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list