Automatic Inference for Both Key and Value Types of an Associative Array

Meta via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 15 11:24:31 PDT 2014


On Friday, 15 August 2014 at 08:34:22 UTC, Kenji Hara via 
Digitalmars-d wrote:
> I implemented partial type deduction in AA keys.
> https://github.com/D-Programming-Language/dmd/pull/3615
>
> For example:
>     auto[auto[$]] aa5 = [[1,2]:1, [3,4]:2];
>     static assert(is(typeof(aa5) == int[int[2]]));
>
>     int[int[][$]] aa15 = [[[1],[2]]:1, [[3],[4]]:2];
>     static assert(is(typeof(aa15) == int[int[][2]]));
>
> Kenji Hara

Neat. I see as well that you thought of a case that I didn't:

auto[shared const] aa4 = [1:1, 2:2]

I think this partial type inference is a very interesting feature.


More information about the Digitalmars-d mailing list