digitalmars.D.learn - untuple a tuple
if I have something like
template t(args...)
{
pragma(msg, args);
}
it prints out args in a tuple... e.g.,
tuple!(...)
I do not want it to print out the tuple!().
I can write my own pragma and pass each arg to it (e.g.,
pragma(msg, arg[0], arg[1], ...)) but this is not very general
and requires a lot of static if's (one for each possible n).
Is it possible to "untuple"?
Jul 29 2013
On Monday, 29 July 2013 at 16:57:49 UTC, JS wrote:
if I have something like
template t(args...)
{
pragma(msg, args);
}
it prints out args in a tuple... e.g.,
tuple!(...)
I do not want it to print out the tuple!().
I can write my own pragma and pass each arg to it (e.g.,
pragma(msg, arg[0], arg[1], ...)) but this is not very general
and requires a lot of static if's (one for each possible n).
Is it possible to "untuple"?
template t(args...)
{
pragma(msg, args);
}
void main()
{
alias f = t!(int, double, string);
}
Prints `(int, double, string)` for me, with no `tuple!` part.
However, putting it in a template means you need an alias, so
it's probably better to make it a function instead.
void t(args...)()
{
pragma(msg, args);
}
void main()
{
t!(int, double, string);
}
Jul 29 2013








"Meta" <jared771 gmail.com>