__traits(compiles) + mixin

cal callumenator at gmail.com
Mon Mar 4 23:53:12 PST 2013


I'm confused about this:

import std.conv;

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

This does not compile, giving errors about instantiating 
std.conv.to!(int).to!(string). If I switch the order of lines 1 
and 2 it compiles. Is this a bug or something I don't understand 
about __traits(compiles)?


More information about the Digitalmars-d-learn mailing list