Places a TypeTuple can be used

Ali Çehreli acehreli at yahoo.com
Fri Aug 16 14:41:10 PDT 2013


On 08/16/2013 09:02 AM, Dicebot wrote:

 > It does complicate things that sometimes TypeTuple is accepted in cases
 > where comma-separated list does not:
 >
 > import std.typetuple;
 >
 > void main()
 > {
 >      //alias TT = TypeTuple!(int, string);
 >      //TT twoVars;
 >      (int, string) twoVars; // do you expect this to work?
 >      static assert(is(typeof(twoVars[0]) == int));
 >      static assert(is(typeof(twoVars[1]) == string));
 > }

No, I would not expect that line to work.

However, I am totally amazed that your commented-out code works! Wow! :)

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



More information about the Digitalmars-d-learn mailing list