Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/assert.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
comparison
equal
deleted
inserted
replaced
100:793467b5e61c | 101:c530137014c0 |
---|---|
1 // | 1 // |
2 // boost/assert.hpp - BOOST_ASSERT(expr) | 2 // boost/assert.hpp - BOOST_ASSERT(expr) |
3 // BOOST_ASSERT_MSG(expr, msg) | 3 // BOOST_ASSERT_MSG(expr, msg) |
4 // BOOST_VERIFY(expr) | 4 // BOOST_VERIFY(expr) |
5 // BOOST_VERIFY_MSG(expr, msg) | |
5 // | 6 // |
6 // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. | 7 // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. |
7 // Copyright (c) 2007 Peter Dimov | 8 // Copyright (c) 2007, 2014 Peter Dimov |
8 // Copyright (c) Beman Dawes 2011 | 9 // Copyright (c) Beman Dawes 2011 |
9 // | 10 // |
10 // Distributed under the Boost Software License, Version 1.0. (See | 11 // Distributed under the Boost Software License, Version 1.0. |
11 // accompanying file LICENSE_1_0.txt or copy at | 12 // See accompanying file LICENSE_1_0.txt or copy at |
12 // http://www.boost.org/LICENSE_1_0.txt) | 13 // http://www.boost.org/LICENSE_1_0.txt |
13 // | 14 // |
14 // Note: There are no include guards. This is intentional. | 15 // Note: There are no include guards. This is intentional. |
15 // | 16 // |
16 // See http://www.boost.org/libs/utility/assert.html for documentation. | 17 // See http://www.boost.org/libs/assert/assert.html for documentation. |
17 // | 18 // |
18 | 19 |
19 // | 20 // |
20 // Stop inspect complaining about use of 'assert': | 21 // Stop inspect complaining about use of 'assert': |
21 // | 22 // |
22 // boostinspect:naassert_macro | 23 // boostinspect:naassert_macro |
23 // | 24 // |
24 | 25 |
25 //--------------------------------------------------------------------------------------// | 26 // |
26 // BOOST_ASSERT // | 27 // BOOST_ASSERT, BOOST_ASSERT_MSG |
27 //--------------------------------------------------------------------------------------// | 28 // |
28 | 29 |
29 #undef BOOST_ASSERT | 30 #undef BOOST_ASSERT |
31 #undef BOOST_ASSERT_MSG | |
30 | 32 |
31 #if defined(BOOST_DISABLE_ASSERTS) | 33 #if defined(BOOST_DISABLE_ASSERTS) || ( defined(BOOST_ENABLE_ASSERT_DEBUG_HANDLER) && defined(NDEBUG) ) |
32 | 34 |
33 # define BOOST_ASSERT(expr) ((void)0) | 35 # define BOOST_ASSERT(expr) ((void)0) |
36 # define BOOST_ASSERT_MSG(expr, msg) ((void)0) | |
34 | 37 |
35 #elif defined(BOOST_ENABLE_ASSERT_HANDLER) | 38 #elif defined(BOOST_ENABLE_ASSERT_HANDLER) || ( defined(BOOST_ENABLE_ASSERT_DEBUG_HANDLER) && !defined(NDEBUG) ) |
36 | 39 |
37 #include <boost/config.hpp> | 40 #include <boost/config.hpp> // for BOOST_LIKELY |
38 #include <boost/current_function.hpp> | 41 #include <boost/current_function.hpp> |
39 | 42 |
40 namespace boost | 43 namespace boost |
41 { | 44 { |
42 void assertion_failed(char const * expr, | 45 void assertion_failed(char const * expr, char const * function, char const * file, long line); // user defined |
43 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 |
44 } // namespace boost | 47 } // namespace boost |
45 | 48 |
46 #define BOOST_ASSERT(expr) (BOOST_LIKELY(!!(expr)) \ | 49 #define BOOST_ASSERT(expr) (BOOST_LIKELY(!!(expr))? ((void)0): ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)) |
47 ? ((void)0) \ | 50 #define BOOST_ASSERT_MSG(expr, msg) (BOOST_LIKELY(!!(expr))? ((void)0): ::boost::assertion_failed_msg(#expr, msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)) |
48 : ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)) | |
49 | 51 |
50 #else | 52 #else |
53 | |
51 # include <assert.h> // .h to support old libraries w/o <cassert> - effect is the same | 54 # include <assert.h> // .h to support old libraries w/o <cassert> - effect is the same |
55 | |
52 # define BOOST_ASSERT(expr) assert(expr) | 56 # define BOOST_ASSERT(expr) assert(expr) |
57 # define BOOST_ASSERT_MSG(expr, msg) assert((expr)&&(msg)) | |
58 | |
53 #endif | 59 #endif |
54 | 60 |
55 //--------------------------------------------------------------------------------------// | 61 // |
56 // BOOST_ASSERT_MSG // | 62 // BOOST_VERIFY, BOOST_VERIFY_MSG |
57 //--------------------------------------------------------------------------------------// | 63 // |
58 | |
59 # undef BOOST_ASSERT_MSG | |
60 | |
61 #if defined(BOOST_DISABLE_ASSERTS) || defined(NDEBUG) | |
62 | |
63 #define BOOST_ASSERT_MSG(expr, msg) ((void)0) | |
64 | |
65 #elif defined(BOOST_ENABLE_ASSERT_HANDLER) | |
66 | |
67 #include <boost/config.hpp> | |
68 #include <boost/current_function.hpp> | |
69 | |
70 namespace boost | |
71 { | |
72 void assertion_failed_msg(char const * expr, char const * msg, | |
73 char const * function, char const * file, long line); // user defined | |
74 } // namespace boost | |
75 | |
76 #define BOOST_ASSERT_MSG(expr, msg) (BOOST_LIKELY(!!(expr)) \ | |
77 ? ((void)0) \ | |
78 : ::boost::assertion_failed_msg(#expr, msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)) | |
79 | |
80 #else | |
81 #ifndef BOOST_ASSERT_HPP | |
82 #define BOOST_ASSERT_HPP | |
83 #include <cstdlib> | |
84 #include <iostream> | |
85 #include <boost/config.hpp> | |
86 #include <boost/current_function.hpp> | |
87 | |
88 // IDE's like Visual Studio perform better if output goes to std::cout or | |
89 // some other stream, so allow user to configure output stream: | |
90 #ifndef BOOST_ASSERT_MSG_OSTREAM | |
91 # define BOOST_ASSERT_MSG_OSTREAM std::cerr | |
92 #endif | |
93 | |
94 namespace boost | |
95 { | |
96 namespace assertion | |
97 { | |
98 namespace detail | |
99 { | |
100 // Note: The template is needed to make the function non-inline and avoid linking errors | |
101 template< typename CharT > | |
102 BOOST_NOINLINE void assertion_failed_msg(CharT const * expr, char const * msg, char const * function, | |
103 char const * file, long line) | |
104 { | |
105 BOOST_ASSERT_MSG_OSTREAM | |
106 << "***** Internal Program Error - assertion (" << expr << ") failed in " | |
107 << function << ":\n" | |
108 << file << '(' << line << "): " << msg << std::endl; | |
109 #ifdef UNDER_CE | |
110 // The Windows CE CRT library does not have abort() so use exit(-1) instead. | |
111 std::exit(-1); | |
112 #else | |
113 std::abort(); | |
114 #endif | |
115 } | |
116 } // detail | |
117 } // assertion | |
118 } // detail | |
119 #endif | |
120 | |
121 #define BOOST_ASSERT_MSG(expr, msg) (BOOST_LIKELY(!!(expr)) \ | |
122 ? ((void)0) \ | |
123 : ::boost::assertion::detail::assertion_failed_msg(#expr, msg, \ | |
124 BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)) | |
125 #endif | |
126 | |
127 //--------------------------------------------------------------------------------------// | |
128 // BOOST_VERIFY // | |
129 //--------------------------------------------------------------------------------------// | |
130 | 64 |
131 #undef BOOST_VERIFY | 65 #undef BOOST_VERIFY |
66 #undef BOOST_VERIFY_MSG | |
132 | 67 |
133 #if defined(BOOST_DISABLE_ASSERTS) || ( !defined(BOOST_ENABLE_ASSERT_HANDLER) && defined(NDEBUG) ) | 68 #if defined(BOOST_DISABLE_ASSERTS) || ( !defined(BOOST_ENABLE_ASSERT_HANDLER) && defined(NDEBUG) ) |
134 | 69 |
135 # define BOOST_VERIFY(expr) ((void)(expr)) | 70 # define BOOST_VERIFY(expr) ((void)(expr)) |
71 # define BOOST_VERIFY_MSG(expr, msg) ((void)(expr)) | |
136 | 72 |
137 #else | 73 #else |
138 | 74 |
139 # define BOOST_VERIFY(expr) BOOST_ASSERT(expr) | 75 # define BOOST_VERIFY(expr) BOOST_ASSERT(expr) |
76 # define BOOST_VERIFY_MSG(expr, msg) BOOST_ASSERT_MSG(expr,msg) | |
140 | 77 |
141 #endif | 78 #endif |