Chris@16
|
1 //
|
Chris@16
|
2 // boost/assert.hpp - BOOST_ASSERT(expr)
|
Chris@16
|
3 // BOOST_ASSERT_MSG(expr, msg)
|
Chris@16
|
4 // BOOST_VERIFY(expr)
|
Chris@101
|
5 // BOOST_VERIFY_MSG(expr, msg)
|
Chris@16
|
6 //
|
Chris@16
|
7 // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
|
Chris@101
|
8 // Copyright (c) 2007, 2014 Peter Dimov
|
Chris@16
|
9 // Copyright (c) Beman Dawes 2011
|
Chris@16
|
10 //
|
Chris@101
|
11 // Distributed under the Boost Software License, Version 1.0.
|
Chris@101
|
12 // See accompanying file LICENSE_1_0.txt or copy at
|
Chris@101
|
13 // http://www.boost.org/LICENSE_1_0.txt
|
Chris@16
|
14 //
|
Chris@16
|
15 // Note: There are no include guards. This is intentional.
|
Chris@16
|
16 //
|
Chris@101
|
17 // See http://www.boost.org/libs/assert/assert.html for documentation.
|
Chris@16
|
18 //
|
Chris@16
|
19
|
Chris@16
|
20 //
|
Chris@16
|
21 // Stop inspect complaining about use of 'assert':
|
Chris@16
|
22 //
|
Chris@16
|
23 // boostinspect:naassert_macro
|
Chris@16
|
24 //
|
Chris@16
|
25
|
Chris@101
|
26 //
|
Chris@101
|
27 // BOOST_ASSERT, BOOST_ASSERT_MSG
|
Chris@101
|
28 //
|
Chris@16
|
29
|
Chris@16
|
30 #undef BOOST_ASSERT
|
Chris@101
|
31 #undef BOOST_ASSERT_MSG
|
Chris@16
|
32
|
Chris@101
|
33 #if defined(BOOST_DISABLE_ASSERTS) || ( defined(BOOST_ENABLE_ASSERT_DEBUG_HANDLER) && defined(NDEBUG) )
|
Chris@16
|
34
|
Chris@16
|
35 # define BOOST_ASSERT(expr) ((void)0)
|
Chris@101
|
36 # define BOOST_ASSERT_MSG(expr, msg) ((void)0)
|
Chris@16
|
37
|
Chris@101
|
38 #elif defined(BOOST_ENABLE_ASSERT_HANDLER) || ( defined(BOOST_ENABLE_ASSERT_DEBUG_HANDLER) && !defined(NDEBUG) )
|
Chris@16
|
39
|
Chris@101
|
40 #include <boost/config.hpp> // for BOOST_LIKELY
|
Chris@16
|
41 #include <boost/current_function.hpp>
|
Chris@16
|
42
|
Chris@16
|
43 namespace boost
|
Chris@16
|
44 {
|
Chris@101
|
45 void assertion_failed(char const * expr, char const * function, char const * file, long line); // user defined
|
Chris@101
|
46 void assertion_failed_msg(char const * expr, char const * msg, char const * function, char const * file, long line); // user defined
|
Chris@16
|
47 } // namespace boost
|
Chris@16
|
48
|
Chris@101
|
49 #define BOOST_ASSERT(expr) (BOOST_LIKELY(!!(expr))? ((void)0): ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
|
Chris@101
|
50 #define BOOST_ASSERT_MSG(expr, msg) (BOOST_LIKELY(!!(expr))? ((void)0): ::boost::assertion_failed_msg(#expr, msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
|
Chris@16
|
51
|
Chris@16
|
52 #else
|
Chris@101
|
53
|
Chris@16
|
54 # include <assert.h> // .h to support old libraries w/o <cassert> - effect is the same
|
Chris@101
|
55
|
Chris@16
|
56 # define BOOST_ASSERT(expr) assert(expr)
|
Chris@101
|
57 # define BOOST_ASSERT_MSG(expr, msg) assert((expr)&&(msg))
|
Chris@101
|
58
|
Chris@16
|
59 #endif
|
Chris@16
|
60
|
Chris@101
|
61 //
|
Chris@101
|
62 // BOOST_VERIFY, BOOST_VERIFY_MSG
|
Chris@101
|
63 //
|
Chris@16
|
64
|
Chris@16
|
65 #undef BOOST_VERIFY
|
Chris@101
|
66 #undef BOOST_VERIFY_MSG
|
Chris@16
|
67
|
Chris@16
|
68 #if defined(BOOST_DISABLE_ASSERTS) || ( !defined(BOOST_ENABLE_ASSERT_HANDLER) && defined(NDEBUG) )
|
Chris@16
|
69
|
Chris@16
|
70 # define BOOST_VERIFY(expr) ((void)(expr))
|
Chris@101
|
71 # define BOOST_VERIFY_MSG(expr, msg) ((void)(expr))
|
Chris@16
|
72
|
Chris@16
|
73 #else
|
Chris@16
|
74
|
Chris@16
|
75 # define BOOST_VERIFY(expr) BOOST_ASSERT(expr)
|
Chris@101
|
76 # define BOOST_VERIFY_MSG(expr, msg) BOOST_ASSERT_MSG(expr,msg)
|
Chris@16
|
77
|
Chris@16
|
78 #endif
|