tags:

views:

104

answers:

1

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  A: 

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.

Matthieu M.
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.
KitsuneYMG