On Thursday, 6 August 2020 at 21:50:06 UTC, Per Nordlöw wrote:
I just discovered that the is-operator can be used as in
template ElementType(R)
{
static if (is(typeof(R.init.front.init) T))
alias ElementType = T;
else
alias ElementType = void;
}
. Very powerful. Is this documented?
Yes, in the following paragraph under "IsExpression" [1]:
Identifier is declared to be an alias of the resulting type if
the condition is satisfied. The Identifier forms can only be
used if the IsExpression appears in a StaticIfCondition.
[1] https://dlang.org/spec/expression.html#is_expression