Syntax of isExpression

Alex via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jan 31 02:49:40 PST 2017


Hey guys,
could you help me understand the syntax of the isExpression?
I have an example, leaned on documentation

https://dlang.org/spec/expression.html#IsExpression

case 7.

// Code starts here //
import std.stdio, std.typecons;

alias Tup = Tuple!(int, string, bool);

enum myType {a, b, c}

struct E(T, myType ET, bool P) { T parts; }

void main()
{
     auto r = E!(int, myType.a, true)();
     fun(Tup.init);
     writeln("-----");
     fun(r);
}

void fun(T)(T t)
{
     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));
     }
}
// Code ends here //

The question is: why during testing with Tup the last line gives 
"true" and with the struct it is false? Especially, while the 
line before is the same for both cases.


More information about the Digitalmars-d-learn mailing list