BOOST_PP_ASSERT

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

- BOOST_PP_ASSERT_MSG
- BOOST_PP_LIMIT_MAG

#### Requirements

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

#### Sample Code

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

    // The is BOOST_PP_IS_NULLARY macro is not part of
    // the public interface of the library because it
    // doesn't work on Borland preprocessors.  It is
    // only used here to illustrate assertions.  In
    // effect, it detects whether an argument is empty
    // parenthesis or some text.

    #include <boost/preprocessor/detail/is_nullary.hpp>

    #define IS_EDISON_DESIGN_GROUP() \
       BOOST_PP_COMPL( \
          BOOST_PP_IS_NULLARY( \
             BOOST_PP_CAT(IS_EDG_CHECK, __EDG_VERSION) \
          ) \
       ) \
       /**/
    #define IS_EDG_CHECK__EDG_VERSION ()

    #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)

© Copyright Housemarque Oy 2002 © Copyright Paul Mensonides 2002

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt)