Debian Codegraph @

third-party/boost-math/include/boost/math/tools/assert.hpp

raw
1 // (C) Copyright Matt Borland 2021.
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 //
6 // We deliberately use assert in here:
7 //
8 // boost-no-inspect
9
10 #ifndef BOOST_MATH_TOOLS_ASSERT_HPP
11 #define BOOST_MATH_TOOLS_ASSERT_HPP
12
13 #include <boost/math/tools/config.hpp>
14
15 #ifdef BOOST_MATH_HAS_GPU_SUPPORT
16
17 // Run time asserts are generally unsupported
18
19 #define BOOST_MATH_ASSERT(expr)
20 #define BOOST_MATH_ASSERT_MSG(expr, msg)
21 #define BOOST_MATH_STATIC_ASSERT(expr) static_assert(expr, #expr " failed")
22 #define BOOST_MATH_STATIC_ASSERT_MSG(expr, msg) static_assert(expr, msg)
23
24 #else
25
26 #include <boost/math/tools/is_standalone.hpp>
27
28 #ifndef BOOST_MATH_STANDALONE
29
30 #include <boost/assert.hpp>
31 #include <boost/static_assert.hpp>
32 #define BOOST_MATH_ASSERT(expr) BOOST_ASSERT(expr)
33 #define BOOST_MATH_ASSERT_MSG(expr, msg) BOOST_ASSERT_MSG(expr, msg)
34 #define BOOST_MATH_STATIC_ASSERT(expr) BOOST_STATIC_ASSERT(expr)
35 #define BOOST_MATH_STATIC_ASSERT_MSG(expr, msg) BOOST_STATIC_ASSERT_MSG(expr, msg)
36
37 #else // Standalone mode - use cassert
38
39 #include <cassert>
40 #define BOOST_MATH_ASSERT(expr) assert(expr)
41 #define BOOST_MATH_ASSERT_MSG(expr, msg) assert((expr)&&(msg))
42 #define BOOST_MATH_STATIC_ASSERT(expr) static_assert(expr, #expr " failed")
43 #define BOOST_MATH_STATIC_ASSERT_MSG(expr, msg) static_assert(expr, msg)
44
45 #endif // Is standalone
46
47 #endif // BOOST_MATH_HAS_GPU_SUPPORT
48
49 #endif // BOOST_MATH_TOOLS_ASSERT_HPP