1 // can select types 2 static assert(is(Select!(true, int, long) == int)); 3 static assert(is(Select!(false, int, long) == long)); 4 static struct Foo {} 5 static assert(is(Select!(false, const(int), const(Foo)) == const(Foo))); 6 7 // can select symbols 8 int a = 1; 9 int b = 2; 10 alias selA = Select!(true, a, b); 11 alias selB = Select!(false, a, b); 12 assert(selA == 1); 13 assert(selB == 2); 14 15 // can select (compile-time) expressions 16 enum val = Select!(false, -4, 9 - 6); 17 static assert(val == 3);
Aliases itself to T[0] if the boolean condition is true and to T[1] otherwise.