Places a TypeTuple can be used
John Colvin
john.loughran.colvin at gmail.com
Fri Aug 16 16:38:50 PDT 2013
On Friday, 16 August 2013 at 21:41:10 UTC, Ali Çehreli wrote:
> import std.typetuple;
>
> void main()
> {
> alias TT = TypeTuple!(int, string);
> TT twoVars;
> static assert(is(typeof(twoVars[0]) == int));
> static assert(is(typeof(twoVars[1]) == string));
> }
>
> I am speechless. :)
>
> Ali
Seeing as TypeTuple aliases itself away on instantiation (There
is no such thing as a TypeTuple, only a builtin tuple created
with TypeTuple), this is the same principle as
void foo(T ...)()
{
T t = T.init;
foreach(el; t)
write(el,",");
}
foo!(int, double)(); //prints: "0,nan"
More information about the Digitalmars-d-learn
mailing list