exception.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // Boost.Geometry Index
  2. //
  3. // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
  4. //
  5. // Use, modification and distribution is subject to the Boost Software License,
  6. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. #ifndef BOOST_GEOMETRY_INDEX_DETAIL_EXCEPTION_HPP
  9. #define BOOST_GEOMETRY_INDEX_DETAIL_EXCEPTION_HPP
  10. #ifndef BOOST_NO_EXCEPTIONS
  11. #include <stdexcept>
  12. #else
  13. #include <cstdlib>
  14. #endif
  15. namespace boost { namespace geometry { namespace index { namespace detail {
  16. #ifndef BOOST_NO_EXCEPTIONS
  17. inline void throw_runtime_error(const char * str)
  18. {
  19. throw std::runtime_error(str);
  20. }
  21. inline void throw_logic_error(const char * str)
  22. {
  23. throw std::logic_error(str);
  24. }
  25. inline void throw_invalid_argument(const char * str)
  26. {
  27. throw std::invalid_argument(str);
  28. }
  29. inline void throw_length_error(const char * str)
  30. {
  31. throw std::length_error(str);
  32. }
  33. #else
  34. inline void throw_runtime_error(const char * str)
  35. {
  36. BOOST_ASSERT_MSG(!"runtime_error thrown", str);
  37. std::abort();
  38. }
  39. inline void throw_logic_error(const char * str)
  40. {
  41. BOOST_ASSERT_MSG(!"logic_error thrown", str);
  42. std::abort();
  43. }
  44. inline void throw_invalid_argument(const char * str)
  45. {
  46. BOOST_ASSERT_MSG(!"invalid_argument thrown", str);
  47. std::abort();
  48. }
  49. inline void throw_length_error(const char * str)
  50. {
  51. BOOST_ASSERT_MSG(!"length_error thrown", str);
  52. std::abort();
  53. }
  54. #endif
  55. }}}} // namespace boost::geometry::index::detail
  56. #endif // BOOST_GEOMETRY_INDEX_DETAIL_EXCEPTION_HPP