Search code examples
c++debuggingboostmetaprogrammingstatic-assert

boost static_assert with message?


on 1.43 boost it seems that BOOST_STATIC_ASSERT just allows to put a boolean value, is there some alternative that allows me to display a message as well on the compile error?


Solution

  • MPL has BOOST_MPL_ASSERT_MSG. E.g. using GCC 4.2. with this:

    BOOST_MPL_ASSERT_MSG(false, THIS_DOESNT_WORK, (void));
    

    ... results in:

    /path/to/file.cpp:42: error: no matching function for call to 
    'assertion_failed(mpl_::failed************ (function()::THIS_DOESNT_WORK::************)())'