On Thursday, 1 September 2016 at 19:32:23 UTC, Timon Gehr wrote:
Well, I'd argue that's not quite right and the correct
interpretation is
"If not the other X then this X", due to the
`!__traits(compiles,
.f!T)`, explicitly telling the compiler to check if the *other*
"overloads" compile.
Even if that was the intention of the compiler implementation,
the example below demonstrates why it cannot work.
I don't actually know whether template constraints
are considered to be at module scope or in the template scope,
though,
so maybe I'm completely wrong on this.
...
Template scope, but /nothing/ about '.' says "other".
It means to look up the symbol f at module scope, so I guess it
depends on whether the compiler excludes the current template
from that lookup.
template f() if (someCondition) {}
template f() if (someOtherCondition) {}
template f() if (!__traits(compiles, { alias _ = .f!(); })) {}
Does `.f` refer to all symbols named f at module scope, or all
symbols named f *other than* the symbol for which the current
template constraint is being processed?
Actually, I just convinced myself that it's obviously not the
latter and so must be the former, and now I see why this
shouldn't work.