assert.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
  3. // Copyright (c) 2007, 2014 Peter Dimov
  4. // Copyright (c) Beman Dawes 2011
  5. // Copyright (c) 2015 Oracle and/or its affiliates.
  6. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  7. // Use, modification and distribution is subject to the Boost Software License,
  8. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. #ifndef BOOST_GEOMETRY_CORE_ASSERT_HPP
  11. #define BOOST_GEOMETRY_CORE_ASSERT_HPP
  12. #include <boost/assert.hpp>
  13. #undef BOOST_GEOMETRY_ASSERT
  14. #undef BOOST_GEOMETRY_ASSERT_MSG
  15. #if defined(BOOST_GEOMETRY_ENABLE_ASSERT_HANDLER) || ( defined(BOOST_GEOMETRY_ENABLE_ASSERT_DEBUG_HANDLER) && !defined(NDEBUG) )
  16. #include <boost/config.hpp> // for BOOST_LIKELY
  17. #include <boost/current_function.hpp>
  18. namespace boost { namespace geometry
  19. {
  20. void assertion_failed(char const * expr, char const * function, char const * file, long line); // user defined
  21. void assertion_failed_msg(char const * expr, char const * msg, char const * function, char const * file, long line); // user defined
  22. }} // namespace boost::geometry
  23. #define BOOST_GEOMETRY_ASSERT(expr) (BOOST_LIKELY(!!(expr))? ((void)0): ::boost::geometry::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
  24. #define BOOST_GEOMETRY_ASSERT_MSG(expr, msg) (BOOST_LIKELY(!!(expr))? ((void)0): ::boost::geometry::assertion_failed_msg(#expr, msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
  25. #else
  26. #define BOOST_GEOMETRY_ASSERT(expr) BOOST_ASSERT(expr)
  27. #define BOOST_GEOMETRY_ASSERT_MSG(expr, msg) BOOST_ASSERT_MSG(expr, msg)
  28. #endif
  29. #endif // BOOST_GEOMETRY_CORE_EXCEPTION_HPP