Kinds of containers

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Fri Oct 23 10:44:53 PDT 2015


On Friday, 23 October 2015 at 11:03:37 UTC, Andrei Alexandrescu 
wrote:
> On 10/22/15 1:09 AM, deadalnix wrote:
>> The elephant in the room: make the template parameter's type 
>> qualifier
>> transitive with the collection's qualifier.
>
> Could you please give more detail on this? Thanks! -- Andrei

Sure. We have a problem when it come to collection in the fact 
that type qualifier do not turtle down as one would expect.

Collection!T and Collection!const(T) are 2 completely different 
types. There is a good reason for this : static if (is(T == 
const)) { ... } . As a result thing like :

void foo(T)(const Collection!const(T) c) {}
void main() {
   Collection!T c;
   foo(c); // Error, GTFO !
}

With the different qualifiers and implicit conversion, thing 
become quite tricky. You can simulate them partially with a set 
of carefully crafted alias this (but not having multiple alias 
this doesn't make things any simpler) but there is the monster of 
mutually recursive template instanciation that is lurking.

As far as i know, jmdavis had some good work done on this, but it 
was far from perfect.



More information about the Digitalmars-d mailing list