2
// boost/assert.hpp - BOOST_ASSERT(expr)
3
// BOOST_ASSERT_MSG(expr, msg)
6
// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
7
// Copyright (c) 2007 Peter Dimov
8
// Copyright (c) Beman Dawes 2011
10
// Distributed under the Boost Software License, Version 1.0. (See
11
// accompanying file LICENSE_1_0.txt or copy at
12
// http://www.boost.org/LICENSE_1_0.txt)
14
// Note: There are no include guards. This is intentional.
16
// See http://www.boost.org/libs/utility/assert.html for documentation.
20
// Stop inspect complaining about use of 'assert':
22
// boostinspect:naassert_macro
25
//--------------------------------------------------------------------------------------//
27
//--------------------------------------------------------------------------------------//
31
#if defined(BOOST_DISABLE_ASSERTS)
33
# define BOOST_ASSERT(expr) ((void)0)
35
#elif defined(BOOST_ENABLE_ASSERT_HANDLER)
37
#include <boost/current_function.hpp>
41
void assertion_failed(char const * expr,
42
char const * function, char const * file, long line); // user defined
45
#define BOOST_ASSERT(expr) ((expr) \
47
: ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
50
# include <assert.h> // .h to support old libraries w/o <cassert> - effect is the same
51
# define BOOST_ASSERT(expr) assert(expr)
54
//--------------------------------------------------------------------------------------//
55
// BOOST_ASSERT_MSG //
56
//--------------------------------------------------------------------------------------//
58
# undef BOOST_ASSERT_MSG
60
#if defined(BOOST_DISABLE_ASSERTS) || defined(NDEBUG)
62
#define BOOST_ASSERT_MSG(expr, msg) ((void)0)
64
#elif defined(BOOST_ENABLE_ASSERT_HANDLER)
66
#include <boost/current_function.hpp>
70
void assertion_failed_msg(char const * expr, char const * msg,
71
char const * function, char const * file, long line); // user defined
74
#define BOOST_ASSERT_MSG(expr, msg) ((expr) \
76
: ::boost::assertion_failed_msg(#expr, msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
79
#ifndef BOOST_ASSERT_HPP
80
#define BOOST_ASSERT_HPP
83
#include <boost/current_function.hpp>
85
// IDE's like Visual Studio perform better if output goes to std::cout or
86
// some other stream, so allow user to configure output stream:
87
#ifndef BOOST_ASSERT_MSG_OSTREAM
88
# define BOOST_ASSERT_MSG_OSTREAM std::cerr
97
inline void assertion_failed_msg(char const * expr, char const * msg, char const * function,
98
char const * file, long line)
100
BOOST_ASSERT_MSG_OSTREAM
101
<< "***** Internal Program Error - assertion (" << expr << ") failed in "
103
<< file << '(' << line << "): " << msg << std::endl;
111
#define BOOST_ASSERT_MSG(expr, msg) ((expr) \
113
: ::boost::assertion::detail::assertion_failed_msg(#expr, msg, \
114
BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
117
//--------------------------------------------------------------------------------------//
119
//--------------------------------------------------------------------------------------//
123
#if defined(BOOST_DISABLE_ASSERTS) || ( !defined(BOOST_ENABLE_ASSERT_HANDLER) && defined(NDEBUG) )
125
# define BOOST_VERIFY(expr) ((void)(expr))
129
# define BOOST_VERIFY(expr) BOOST_ASSERT(expr)