On Monday, 29 October 2012 at 10:58:51 UTC, Philippe Sigaud wrote:
Tell me please,in this code first and second static if,are these equivalent?
with arg = 1, __traits(compiles,"check(arg);") = true,
is(typeof(check(arg))) = false.

__traits(compiles, ...) takes an expression, not a string. From the spec: "The arguments can be symbols, types, or expressions that are
syntactically correct. The arguments cannot be statements or
declarations."

(http://dlang.org/traits.html#compiles)

So, in your case, that would be:

__traits(compiles, {check(arg);})

Note that you can also use the type of arg:

__traits(compiles, {check(typeof(arg).init);})

or

is(typeof({ check(typeof(arg).init);})
Thank you,understood.

Reply via email to