The BOOST_PP_ASSERT macro conditionally causes a preprocessing error.

Usage

BOOST_PP_ASSERT(cond)

Arguments

cond
A condition that determines whether an assertion occurs.  Valid values range from 0 to BOOST_PP_LIMIT_MAG.

Remarks

If cond expands to 0, this macro causes a preprocessing error.  Otherwise, it expands to nothing.

See Also

Requirements

Header:  <boost/preprocessor/debug/assert.hpp>

Sample Code

#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/debug/assert.hpp>
#include <boost/preprocessor/detail/is_nullary.hpp>
#include <boost/preprocessor/logical/bitnor.hpp>
#include <boost/preprocessor/logical/compl.hpp>

#define IS_EDISON_DESIGN_GROUP() /* ..... */ \
   BOOST_PP_COMPL(                           \
      BOOST_PP_IS_NULLARY(                   \
         BOOST_PP_CAT(IS_EDG_CHECK, __EDG__) \
      )                                      \
   )                                         \
   /**/
#define IS_EDG_CHECK__EDG__ ()

#define IS_METROWERKS() /* .................... */ \
   BOOST_PP_COMPL(                                 \
      BOOST_PP_IS_NULLARY(                         \
         BOOST_PP_CAT(IS_MWERKS_CHECK, __MWERKS__) \
      )                                            \
   )                                               \
   /**/
#define IS_MWERKS_CHECK__MWERKS__ ()

#define IS_MICROSOFT() /* ... */ \
   BOOST_PP_BITNOR(              \
      IS_MICROSOFT_ROOT(),       \
      IS_EDISON_DESIGN_GROUP()   \
   )                             \
   /**/
#define IS_MICROSOFT_ROOT() /* ......... */ \
   BOOST_PP_IS_NULLARY(                     \
      BOOST_PP_CAT(IS_MSVC_CHECK, _MSC_VER) \
   )                                        \
   /**/
#define IS_MSVC_CHECK_MS_VER ()

// this macro doesn't work on EDG...
// (this is just an example)

#define MACRO(n) /* ....... */ \
   BOOST_PP_CAT(               \
      MACRO_,                  \
      IS_EDISON_DESIGN_GROUP() \
   )(n)                        \
   /**/

#define MACRO_1(n) /* ................ */ \
   BOOST_PP_ASSERT(0)                     \
   "Edison Design Group is not supported" \
   /**/

#define MACRO_0(n) normal mode: n

MACRO(10)