digitalmars.D.learn - unqualified types in tuple
- "Dan" <dbdavidson yahoo.com> Nov 21 2012
- Philippe Sigaud <philippe.sigaud gmail.com> Nov 21 2012
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
--047d7b66efdfdf30bd04cf089de9
Content-Type: text/plain; charset=UTF-8
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);
}
--047d7b66efdfdf30bd04cf089de9
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
You can use std.typetuple.staticMap to map Unqual on each type:<div><br></d=
iv><div><br></div><div>import std.typetuple;</div><div>import std.stdio;</d=
iv><div><br></div><div><div>template UnqualifyTuple(T...)</div><div>{</div>
<div>=C2=A0 =C2=A0 alias staticMap!(Unqual, T) UnqualifyTuple;</div><div>}<=
/div><div><br></div><div>void main()</div><div>{</div><div>=C2=A0 =C2=A0 al=
ias TypeTuple!(const(int), immutable(double), string) TL;</div><div>=C2=A0 =
=C2=A0 writeln(TL.stringof);</div>
<div><br></div><div>=C2=A0 =C2=A0 alias UnqualifyTuple!TL UQTL;</div><div>=
=C2=A0 =C2=A0 writeln(UQTL.stringof);</div><div>}</div></div>
--047d7b66efdfdf30bd04cf089de9--
Nov 21 2012








Philippe Sigaud <philippe.sigaud gmail.com>