Le 29/11/09 13:16, Michel Fortin a écrit :
On 2009-11-29 06:14:21 -0500, "Simen kjaeraas" <simen.kja...@gmail.com>
said:

That is because your opDispatch is instantiated no matter what the name
is, but only does something sensible if it's foo. Try this:

string opDispatch( string name )( ) {
static if ( name == "foo" ) {
return "foo";
} else {
static assert( false, "Invalid member name." );
}
}

Wouldn't this be even better?

string opDispatch(string name)() if (name == "foo") {
return "foo";
}

I haven't tested that it works though.


It doesn't improve the error message, but it works. It's been a long time since I used D: I didn't know this syntax!

Reply via email to