CodeBuddy
CodeBuddy

Reputation: 6639

Can BOOST_STATIC_ASSERT give a custom compilation error string?

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.

Upvotes: 2

Views: 606

Answers (1)

Matthieu M.
Matthieu M.

Reputation: 300079

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.

Upvotes: 2

Related Questions