assert.hpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // boost/assert.hpp - BOOST_ASSERT(expr)
  3. //
  4. // Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
  5. // Copyright (c) 2007 Peter Dimov
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See
  8. // accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. //
  11. // Note: There are no include guards. This is intentional.
  12. //
  13. // See http://www.boost.org/libs/utility/assert.html for documentation.
  14. //
  15. #undef BOOST_ASSERT
  16. #if defined(BOOST_DISABLE_ASSERTS)
  17. # define BOOST_ASSERT(expr) ((void)0)
  18. #elif defined(BOOST_ENABLE_ASSERT_HANDLER)
  19. #include <boost/current_function.hpp>
  20. namespace boost
  21. {
  22. void assertion_failed(char const * expr, char const * function, char const * file, long line); // user defined
  23. } // namespace boost
  24. #define BOOST_ASSERT(expr) ((expr)? ((void)0): ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
  25. #else
  26. # include <assert.h> // .h to support old libraries w/o <cassert> - effect is the same
  27. # define BOOST_ASSERT(expr) assert(expr)
  28. #endif
  29. #undef BOOST_VERIFY
  30. #if defined(BOOST_DISABLE_ASSERTS) || ( !defined(BOOST_ENABLE_ASSERT_HANDLER) && defined(NDEBUG) )
  31. # define BOOST_VERIFY(expr) ((void)(expr))
  32. #else
  33. # define BOOST_VERIFY(expr) BOOST_ASSERT(expr)
  34. #endif