Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
c++boost.gif (8819 bytes)



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. Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose.