# assert.hpp

The header <boost/assert.hpp> defines the macro BOOST_ASSERT, which is similar to the standard assert macro defined in <cassert>. The macro is intended to be used in Boost libraries.

By default, `BOOST_ASSERT(expr)` is equivalent to `assert(expr)`.

When the macro BOOST_DISABLE_ASSERTS is defined when <boost/assert.hpp> is included, `BOOST_ASSERT(expr)` is defined as `((void)0)`. This allows users to selectively disable BOOST_ASSERT without affecting the definition of the standard assert.

When the macro BOOST_ENABLE_ASSERT_HANDLER is defined when <boost/assert.hpp> is included, `BOOST_ASSERT(expr)` evaluates expr and, if the result is false, evaluates the expression

`::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)`

assertion_failed is declared in <boost/assert.hpp> as

    namespace boost
    {

    void assertion_failed(char const * expr, char const * function, char const * file, long line);

    }

but it is never defined. The user is expected to supply an appropriate definition.

As is the case with <cassert>, <boost/assert.hpp> can be included multiple times in a single translation unit. BOOST_ASSERT will be redefined each time as specified above.

Copyright © 2002 by Peter Dimov. Distributed under the Boost Software License, Version 1.0. See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.