assert.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #ifndef BOOST_MATH_TOOLS_ASSERT_HPP
  10. #define BOOST_MATH_TOOLS_ASSERT_HPP
  11. #include <boost/math/tools/config.hpp>
  12. #ifdef BOOST_MATH_HAS_GPU_SUPPORT
  13. // Run time asserts are generally unsupported
  14. #define BOOST_MATH_ASSERT(expr)
  15. #define BOOST_MATH_ASSERT_MSG(expr, msg)
  16. #define BOOST_MATH_STATIC_ASSERT(expr) static_assert(expr, #expr " failed")
  17. #define BOOST_MATH_STATIC_ASSERT_MSG(expr, msg) static_assert(expr, msg)
  18. #else
  19. #include <boost/math/tools/is_standalone.hpp>
  20. #ifndef BOOST_MATH_STANDALONE
  21. #include <boost/assert.hpp>
  22. #include <boost/static_assert.hpp>
  23. #define BOOST_MATH_ASSERT(expr) BOOST_ASSERT(expr)
  24. #define BOOST_MATH_ASSERT_MSG(expr, msg) BOOST_ASSERT_MSG(expr, msg)
  25. #define BOOST_MATH_STATIC_ASSERT(expr) BOOST_STATIC_ASSERT(expr)
  26. #define BOOST_MATH_STATIC_ASSERT_MSG(expr, msg) BOOST_STATIC_ASSERT_MSG(expr, msg)
  27. #else // Standalone mode - use cassert
  28. #include <cassert>
  29. #define BOOST_MATH_ASSERT(expr) assert(expr)
  30. #define BOOST_MATH_ASSERT_MSG(expr, msg) assert((expr)&&(msg))
  31. #define BOOST_MATH_STATIC_ASSERT(expr) static_assert(expr, #expr " failed")
  32. #define BOOST_MATH_STATIC_ASSERT_MSG(expr, msg) static_assert(expr, msg)
  33. #endif // Is standalone
  34. #endif // BOOST_MATH_HAS_GPU_SUPPORT
  35. #endif // BOOST_MATH_TOOLS_ASSERT_HPP