Alias/Ref Tuples ?

Joshua Reusch yoschi at arkandos.de
Fri Dec 16 22:30:48 PST 2011


Am 17.12.2011 01:23, schrieb Simen Kjærås:
> On Fri, 16 Dec 2011 14:00:11 +0100, Joshua Reusch <yoschi at arkandos.de>
> wrote:
>
>> Hello,
>>
>> is there a way to say something like
>>
>> ---
>> int a, b;
>> AliasTuple!(a, b) = tuple(4,5);
>> assert(a == 4 && b == 5);
>> ---
>>
>> without having to write an own AliasTuple template ? I want to use it
>> for functions returning multiple values.
>
> A few small tests later:
>
> import std.typetuple;
> import std.typecons;
> import std.stdio;
>
> void main() {
> int a, b;
> TypeTuple!(a, b) = tuple(4,5);
> assert(a == 4 && b == 5);
> }
>
> In other words, the language already has this.
>
> Note that TypeTuple!(a,b) = TypeTuple!(b,a) also works, but sets both a
> and b equal to b.

Thank you ! This is exactly what I needed ! I didnt thought TypeTuple 
can do this.


More information about the Digitalmars-d-learn mailing list