If line A is changed to "auto x = foo(1,2);" then the code compiles without incident. This should compile with one parameter as well.
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); // A
}
Comment #1 by bearophile_hugs — 2010-06-04T16:55:10Z
I don't understand the purpose of your code, but I think the problems are in your code.
Maybe in fooRet you meant to use:
alias T[0] fooRet;
You can also use:
auto foo(T...)(T vals)
Comment #2 by bugzilla — 2010-06-04T17:16:41Z
"Fixing" this would require conflating a Tuple!(T) with T. I think this would be a mistake.