June 04, 2010 [phobos] Error: functions cannot return a tuple | ||||
|---|---|---|---|---|
| ||||
This is a fun one. I don't suppose someone can suggest a workaround? If an argument is added to the call to foo() in main (so it really does return a Tuple) the code compiles without incident. I ran into this while making sure all the code samples in TDPL ch.13 work.
import std.typecons;
template fooRet(T...)
{
static if( T.length == 1 )
alias T fooRet;
else
alias Tuple!(T) fooRet;
}
fooRet!(T) foo(T...)(T vals)
{
Tuple!(T) ret;
static if( T.length == 1 )
return ret.field[0];
else
return ret;
}
void main()
{
auto x = foo(1)();
}
| ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply