Assert compilation failure with certain message
Jonathan M Davis
jmdavisProg at gmx.com
Thu Feb 10 16:23:07 PST 2011
On Thursday, February 10, 2011 16:12:01 Tomek Sowiński wrote:
> Is there a way to statically assert compilation of an expression failed
> *with a certain message*? I want to check my static asserts trip when they
> should.
You mean like
static assert(0, "We have a failure, Captain!");
If a static assert fails, it's obvious. Compilation fails. Now, if you're trying
to assert something like that a particular template instantiation fails, the use
static assert(!__traits(compiles, exp)); where exp is the expression being
tested.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list