On 27.02.2016 01:03, Jonathan M Davis wrote:
There's nothing cheating about using __traits(compiles). It's basically
the same as using is(typeof(foo)) and is(typeof({statement;})), albeit
arguably a bit more explicit about the fact that it's testing what compiles.
The two are subtly different and only __traits(compiles,...) reliably
checks for compilability. Never use is(typeof(...)) unless you know
exactly what you are doing.
void main(){
int x;
static void foo(){
static assert(is(typeof({return x;})));
static assert(!__traits(compiles,{return x;}));
//auto a={return x;}; // error
}
}