Places a TypeTuple can be used

Meta jared771 at gmail.com
Thu Aug 15 22:39:25 PDT 2013


On Friday, 16 August 2013 at 04:14:04 UTC, Ali Çehreli wrote:
> I know of three places a TypeTuple can be used at:
>
> 1) Function parameter list
>
> 2) Template parameter list
>
> 3) Array literal element list
>
> Are there more?
>
> import std.typetuple;
>
> void foo(int, string, double)
> {}
>
> struct S(T, float f)
> {}
>
> void main()
> {
>     // 1) Function parameter list: May not contain types
>     foo(TypeTuple!(42, "hello", 1.5));
>
>     // 2) Template parameter list: May contain types
>     auto s = S!(TypeTuple!(char, 2.5))();
>
>     // 3) Array elements: Elements must be the same type
>     auto a = [ TypeTuple!(1, 2, 3, 4) ];
>
>     // Are there other places that a TypeTuple can be used?
> }
>
> Ali

I'm not sure if it should be considered a separate case, but 
there is this:

foreach(type; TypeTuple!(ubyte, uint, ulong))
{
     writeln(type.max);
}


More information about the Digitalmars-d-learn mailing list