Search code examples
c++11static-assert

How to remove the default "error: static assertion failed:" and print only my message in static_assert?


Whenever assertion fails in a code like:

static_assert(std::get<0>(tup1) == 0, "Expected value of 0 is not there");

I would like my program to print only the diagnostic Expected value of 0 is not there instead of error: static assertion failed: Expected value of 0 is not there. How to accomplish this?


Solution

  • This is a compiler generated error message that provides some additional context to why the code could not be compiled. It cannot be changed without changing the compiler sources (but don't do that).