www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - unqualified types in tuple

reply "Dan" <dbdavidson yahoo.com> writes:
If I have a type tuple TL, which happens to be:
   alias TypeTuple!(const(int), immutable(double), string) TL;

How can I convert it into a tuple of (int, double, string)?

Effectively I need a way to get a new UnqualTL where each type in 
the list is itself unqualified. I need to do this without knowing 
the alias.

Thanks
Dan
Nov 21 2012
parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
You can use std.typetuple.staticMap to map Unqual on each type:


import std.typetuple;
import std.stdio;

template UnqualifyTuple(T...)
{
    alias staticMap!(Unqual, T) UnqualifyTuple;
}

void main()
{
    alias TypeTuple!(const(int), immutable(double), string) TL;
    writeln(TL.stringof);

    alias UnqualifyTuple!TL UQTL;
    writeln(UQTL.stringof);
}
Nov 21 2012