Multiple return values...

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Mar 9 20:26:29 PST 2012


On 3/9/12 4:10 PM, Timon Gehr wrote:
> (int, int) foo(int a, int b){return (a,b);}
>
> assert(foo(foo(foo(foo(1,2))))==(1,2));
>
> (int, int) goo(int a, int b, int c){return (a+b, c);}
>
> assert(goo(foo(2,3),1) == (5,1));

This is a recipe for disaster because of the implicit expansion. 
Consider forwarding the result of foo to some template. Should the 
template take the tuple type, or automatically expand the tuple and 
accept individual values?

Andrei


More information about the Digitalmars-d mailing list