Multiple return values...

Simen Kjærås simen.kjaras at gmail.com
Wed Mar 14 15:33:20 PDT 2012


On Wed, 14 Mar 2012 22:52:26 +0100, Andrei Alexandrescu  
<SeeWebsiteForEmail at erdani.org> wrote:

> On 3/14/12 3:00 PM, Simen Kjærås wrote:
>> template to(T...) {
>> alias T to;
>> }
>>
>> auto from(T...)(T t) {
>> struct Result { T t; alias t this; }
>> return Result( t );
>> }
>>
>> void main( ) {
>> int a = 3;
>> int b = 4;
>>
>> to!(a, b) = from(b, a);
>>
>> assert( a == 4 );
>> assert( b == 3 );
>> }
>
> I got reborn inside a little when seeing this code. Congratulations!
>
> Andrei

Thank you, and you're welcome.


More information about the Digitalmars-d mailing list