The OpenD Programming Language

Select

Aliases itself to T[0] if the boolean condition is true and to T[1] otherwise.

template Select (
bool condition
T...
) if (
T.length == 2
) {}

Examples

// can select types
static assert(is(Select!(true, int, long) == int));
static assert(is(Select!(false, int, long) == long));
static struct Foo {}
static assert(is(Select!(false, const(int), const(Foo)) == const(Foo)));

// can select symbols
int a = 1;
int b = 2;
alias selA = Select!(true, a, b);
alias selB = Select!(false, a, b);
assert(selA == 1);
assert(selB == 2);

// can select (compile-time) expressions
enum val = Select!(false, -4, 9 - 6);
static assert(val == 3);

Meta