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