Kinds of containers
bitwise via Digitalmars-d
digitalmars-d at puremagic.com
Fri Oct 23 15:26:53 PDT 2015
On Friday, 23 October 2015 at 17:44:55 UTC, deadalnix wrote:
> 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.
Why not just pass a range to foo?
More information about the Digitalmars-d
mailing list