Tuple literal syntax

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Oct 7 14:03:17 PDT 2010


On 10/7/10 15:45 CDT, Simen kjaeraas wrote:
> retard <re at tard.com.invalid> wrote:
>> I guess the other places of confusion
>> are interaction with built-in statements and other features, e.g.
>>
>> auto foo = (1,2,3);
>>
>> auto bar = [foo];
>>
>> Should there be some way to construct a [1,2,3] array from the tuple or
>> should the only be a way to construct arrays of the type tuple!(int)[] or
>> something similar.
>
> The obvious way to do this:
>
> CommonType!T buildArray( T... )( T arg ) {
> return [ arg ];
> }
>
> auto foo = tuple( 1, 2, 3 );
>
> auto bar = buildArray( foo.expand );
>

Nice. Actually buildArray already exists - it's called array() and it 
sits in std.array.

Andrei


More information about the Digitalmars-d mailing list