__traits(compiles) + mixin

cal callumenator at gmail.com
Tue Mar 5 00:09:36 PST 2013


On Tuesday, 5 March 2013 at 08:04:12 UTC, Andrej Mitrovic wrote:
> You can't test declarations inside of __traits(compiles), only 
> expressions. It's in the docs: 
> http://dlang.org/traits.html#compiles

So why does this work:

import std.conv;

void main()
{
     enum s = "`1`.to!int;";
     enum c = __traits(compiles, mixin("{auto x = "~s~";}")); // 
true
}


More information about the Digitalmars-d-learn mailing list