Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 155001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:04:42+00:00 2026-05-11T10:04:42+00:00

As I recall BOOST_MPL_ASSERT was once preferred. Is this still true? Anyone know why?

  • 0

As I recall BOOST_MPL_ASSERT was once preferred. Is this still true? Anyone know why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T10:04:43+00:00Added an answer on May 11, 2026 at 10:04 am

    [Answering my own question]

    It depends. This is an apples to oranges comparison. Although similar, these macros are NOT interchangeable. Here’s a summary of how each works:

    BOOST_STATIC_ASSERT( P ) generates a compilation error if P != true.

    BOOST_MPL_ASSERT(( P )) generates a compilation error if P::type::value != true.

    The latter form, despite requiring double parentheses, is especially useful because it can generate more informative error messages if one uses Boolean nullary Metafunctions from Boost.MPL or TR1’s <type_traits> as predicates.

    Here is an example program that demonstrates how to use (and misuse) these macros:

    #include <boost/static_assert.hpp> #include <boost/mpl/assert.hpp> #include <type_traits> using namespace ::boost::mpl; using namespace ::std::tr1;  struct A {}; struct Z {};  int main() {         // boolean predicates     BOOST_STATIC_ASSERT( true );          // OK     BOOST_STATIC_ASSERT( false );         // assert //  BOOST_MPL_ASSERT( false );            // syntax error! //  BOOST_MPL_ASSERT(( false ));          // syntax error!     BOOST_MPL_ASSERT(( bool_< true > ));  // OK     BOOST_MPL_ASSERT(( bool_< false > )); // assert          // metafunction predicates     BOOST_STATIC_ASSERT(( is_same< A, A >::type::value ));// OK     BOOST_STATIC_ASSERT(( is_same< A, Z >::type::value ));// assert, line 19     BOOST_MPL_ASSERT(( is_same< A, A > ));                // OK     BOOST_MPL_ASSERT(( is_same< A, Z > ));                // assert, line 21     return 0; } 

    For comparison, here are the error messages my compiler (Microsoft Visual C++ 2008) generated for lines 19 and 21 above:

    1>static_assert.cpp(19) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>' 1>        with 1>        [ 1>            x=false 1>        ] 1>static_assert.cpp(21) : error C2664: 'boost::mpl::assertion_failed' : cannot convert parameter 1 from 'boost::mpl::failed ************std::tr1::is_same<_Ty1,_Ty2>::* ***********' to 'boost::mpl::assert<false>::type' 1>        with 1>        [ 1>            _Ty1=A, 1>            _Ty2=Z 1>        ] 1>        No constructor could take the source type, or constructor overload resolution was ambiguous 

    So if you’re using metafunctions (as defined here) as predicates then BOOST_MPL_ASSERT is both less verbose to code and more informative when it asserts.

    For simple boolean predicates, BOOST_STATIC_ASSERT is less verbose to code although its error messages may be less clear (depending on your compiler.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recall reviewing someone else's PHP code once and he had a function or
I recall reading, on multiple occasions and in multiple locations, that when firing the
I recall reading somewhere that using references to smart pointers can cause memory corruption.
I recall hearing that the connection process in mysql was designed to be very
I don't ever recall coming across anything for C that's as extensive as C++'s
I was asked to recall a message I sent out to remove some personal
I seem to recall that there is an HTML tag that escapes absolutely everything
I seem to recall something about avoiding the Immediate If operator ( ?: )
In Office 2003 if I recall correctly you had a record macro option. In
In Matlab, I recall being able to declare an array and initialize it and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.