Tuple enhancement

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sun Oct 16 09:49:43 PDT 2016


On 10/16/2016 11:07 AM, Dmitry Olshansky wrote:
> On 10/16/16 3:58 PM, Andrei Alexandrescu wrote:
>> I was thinking it would be handy if tuples had a way to access a field
>> by name at runtime. E.g.:
>>
>> Tuple!(int, "a", double, "b") t;
>> string x = condition ? "a" : "b";
>> double v = t.get!string(x, 3.14);
>
> I swear I've seen a pull request merged that adds an accessible "names"
> AliasSeq with names of fields. That should be a good starting point.

Sadly it was closed, not merged. And it was a bit more general allowing 
getting a field by name from any struct. -- Andrei



More information about the Digitalmars-d mailing list