Kinds of containers

Kagamin via Digitalmars-d digitalmars-d at puremagic.com
Thu Oct 22 05:39:55 PDT 2015


On Wednesday, 21 October 2015 at 16:25:19 UTC, Jonathan M Davis 
wrote:
> My experience with immutable containers is that their 
> performance is trash precisely because you can't mutate them.

Well, in context of concurrency immutable containers compete with 
concurrent containers, not with mutable single-threaded ones.

On Wednesday, 21 October 2015 at 14:06:43 UTC, Jonathan M Davis 
wrote:
>> 3. Eager value containers.
>
> _Maybe_ this makes sense for specific container types, but in 
> general, it's a horrible idea IMHO. Almost all containers 
> involve allocating something on the heap internally, so the 
> fact that they're treated as values doesn't avoid heap 
> allocations, and reference-counting reference containers solves 
> the problem of the containers living past the end of the 
> lifetime of whatever owns them. And having value type 
> containers is incredibly error-prone - both from an efficiency 
> standpoint and correctness standpoint.

I suppose stl containers are value types because everything is 
value type in C++, they're just consistent. And then you have 3 
or so ways to create a value type and 6 ways to pass it around by 
reference, and you choose what you want.


More information about the Digitalmars-d mailing list