2

Is it possilbe to get BOOST_STATIC_ASSERT to give a custom compilation error message? I belive the following is an attempt to do that in the code base I'm working in.

BOOST_STATIC_ASSERT( (MAX_NUMBER_OF_USERS == 15) && ("MAX_NUMBER_OF_USERS is no longer set to 15") ); 

Personally I'm not sure the error message gives anything - I'd rather have it placed as a comment next to the assert.

1
  • 1
    Also static_assert(condition, "message") from C++0x should already be rather widely supported. Commented Oct 27, 2009 at 16:30

1 Answer 1

2

For static assertion, I would recommend:

BOOST_MPL_ASSERT_MSG

You pass a C++ identifier like 'message' and it will appear in the error stream.

Sign up to request clarification or add additional context in comments.

1 Comment

I would add that the other BOOST_MPL_ASSERT macro is better than static assert since the error message has a lot of *'s in it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.