Collections question

Jakob Ovrum via Digitalmars-d digitalmars-d at
Fri Nov 27 23:26:19 PST 2015

On Friday, 27 November 2015 at 20:14:21 UTC, Andrei Alexandrescu 
> There's some experience in various libraries with both 
> approaches. Which would you prefer?

Another thing: wouldn't providing a custom allocator require a 
separate primitive? I am assuming that the allocator type won't 
be a template parameter, or at least that it will support 

alias Allocator = ...; // some std.allocator type

Allocator alloc;

// empty collection of int with user-specified allocator
auto c = Collection!int.makeCustomAllocation(alloc);

// collection of one allocator using theAllocator
auto c = Collection!Allocator.make(alloc);

// empty collection of Allocator with user-specified allocator
auto c = Collection!Allocator.makeCustomAllocation(alloc);

The last two don't look like they could use the same name. A way 
around this would be to forego variadic construction in favour of 
range construction, but it would necessitate copying of those 
elements, whether with `only` or putting in an array etc.

If we need two names, then opCall becomes less attractive.

More information about the Digitalmars-d mailing list