www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Tuple Arguments - Type or Constant?

reply Xinok <xnknet gmail.com> writes:
Tuples allow either types or constants to be used as arguments.

template tuple(T...);
tuple!(int, 35);

Is there any way to safely tell if a tuple argument is a type or a constant
without getting an error from the compiler?
Jan 24 2007
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Xinok" <xnknet gmail.com> wrote in message 
news:ep91ad$sno$1 digitaldaemon.com...
 Tuples allow either types or constants to be used as arguments.

 template tuple(T...);
 tuple!(int, 35);

 Is there any way to safely tell if a tuple argument is a type or a 
 constant without getting an error from the compiler?
If you use std.typetraits, there is a metafunction isExpressionTuple(). If that returns true, then it's constants; otherwise, it's, well, I guess any mix of types and expressions. But hopefully just types. (this is kind of an ugly thing with tuples, no?)
Jan 24 2007