Syntax of isExpression

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jan 31 03:40:06 PST 2017


On 01/31/2017 02:49 AM, Alex wrote:

 >     auto r = E!(int, myType.a, true)();

 >     static if (is(T : TX!TL, alias TX, TL...))
 >     {
 >         writeln(is(TL[0] == int));
 >         writeln(typeid(TL[1]));
 >         writeln(typeid(TL[2]));
 >         writeln(is(TL[2] == bool));
 >     }

That's because 'true' is not the type 'bool' but a value of bool. You 
can ask whether the type of a value is bool:

         writeln(is(typeof(TL[2]) == bool));

But then it fails for the Tuple case because typeof(bool) is not bool in 
that case. You need to cover all cases if both 'bool' and 'true' mean 
the same thing for you.

Ali



More information about the Digitalmars-d-learn mailing list