1 # /* Copyright (C) 2001 |
1 // |
2 # * Housemarque Oy |
2 // boost/assert.hpp - BOOST_ASSERT(expr) |
3 # * http://www.housemarque.com |
3 // |
4 # * |
4 // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. |
5 # * Distributed under the Boost Software License, Version 1.0. (See |
5 // |
6 # * accompanying file LICENSE_1_0.txt or copy at |
6 // Distributed under the Boost Software License, Version 1.0. (See |
7 # * http://www.boost.org/LICENSE_1_0.txt) |
7 // accompanying file LICENSE_1_0.txt or copy at |
8 # */ |
8 // http://www.boost.org/LICENSE_1_0.txt) |
9 # |
9 // |
10 # /* Revised by Paul Mensonides (2002) */ |
10 // Note: There are no include guards. This is intentional. |
11 # |
11 // |
12 # /* See http://www.boost.org for most recent version. */ |
12 // See http://www.boost.org/libs/utility/assert.html for documentation. |
13 # |
13 // |
14 # ifndef BOOST_PREPROCESSOR_DEBUG_ASSERT_HPP |
14 |
15 # define BOOST_PREPROCESSOR_DEBUG_ASSERT_HPP |
15 #undef BOOST_ASSERT |
16 # |
16 |
17 # include <boost/preprocessor/config/config.hpp> |
17 #if defined(BOOST_DISABLE_ASSERTS) |
18 # include <boost/preprocessor/control/expr_iif.hpp> |
18 |
19 # include <boost/preprocessor/control/iif.hpp> |
19 # define BOOST_ASSERT(expr) ((void)0) |
20 # include <boost/preprocessor/logical/not.hpp> |
20 |
21 # include <boost/preprocessor/tuple/eat.hpp> |
21 #elif defined(BOOST_ENABLE_ASSERT_HANDLER) |
22 # |
22 |
23 # /* BOOST_PP_ASSERT */ |
23 #include <boost/current_function.hpp> |
24 # |
24 |
25 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() |
25 namespace boost |
26 # define BOOST_PP_ASSERT BOOST_PP_ASSERT_D |
26 { |
27 # else |
27 |
28 # define BOOST_PP_ASSERT(cond) BOOST_PP_ASSERT_D(cond) |
28 void assertion_failed(char const * expr, char const * function, char const * file, long line); // user defined |
29 # endif |
29 |
30 # |
30 } // namespace boost |
31 # define BOOST_PP_ASSERT_D(cond) BOOST_PP_IIF(BOOST_PP_NOT(cond), BOOST_PP_ASSERT_ERROR, BOOST_PP_TUPLE_EAT_1)(...) |
31 |
32 # define BOOST_PP_ASSERT_ERROR(x, y, z) |
32 #define BOOST_ASSERT(expr) ((expr)? ((void)0): ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)) |
33 # |
33 |
34 # /* BOOST_PP_ASSERT_MSG */ |
34 #else |
35 # |
35 # include <assert.h> // .h to support old libraries w/o <cassert> - effect is the same |
36 # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() |
36 # define BOOST_ASSERT(expr) assert(expr) |
37 # define BOOST_PP_ASSERT_MSG BOOST_PP_ASSERT_MSG_D |
37 #endif |
38 # else |
|
39 # define BOOST_PP_ASSERT_MSG(cond, msg) BOOST_PP_ASSERT_MSG_D(cond, msg) |
|
40 # endif |
|
41 # |
|
42 # define BOOST_PP_ASSERT_MSG_D(cond, msg) BOOST_PP_EXPR_IIF(BOOST_PP_NOT(cond), msg) |
|
43 # |
|
44 # endif |
|