bearophile wrote:
Michel Fortin:Am I right that what you want is this? static assert(!__traits(compiles, foo(10)));I want a nice syntax that statically asserts if foo(10) doesn't statically asserts :-) What you have written is close (in D1 I have used the is() syntax for a similar purpose), but beside being syntactically ugly, it doesn't specifically detect static asserts inside foo.
It seems pretty useless to me. Wanting to make a distinction between "this will not compile" and "this will not compile _because it hits a static assert_" is an *extremely* niche feature. Because the only times I can imagine that you'd care would be because you wanted to ensure it gave a "nice" error message. And to do that, you'd have to actually check the test of the static assert.
And the idea of creating a whole heirarchy of compile-time exceptions for this ...
