1 // Boost.Geometry Index
2 //
3 // Copyright (c) 2011-2014 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 
9 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_EXCEPTION_HPP
10 #define BOOST_GEOMETRY_INDEX_DETAIL_EXCEPTION_HPP
11 
12 #include <boost/core/no_exceptions_support.hpp>
13 
14 #ifndef BOOST_NO_EXCEPTIONS
15 #include <stdexcept>
16 #include <boost/throw_exception.hpp>
17 #else
18 #include <cstdlib>
19 #include <boost/geometry/index/detail/assert.hpp>
20 #endif
21 
22 namespace boost { namespace geometry { namespace index { namespace detail {
23 
24 #ifndef BOOST_NO_EXCEPTIONS
25 
throw_runtime_error(const char * str)26 inline void throw_runtime_error(const char * str)
27 {
28     BOOST_THROW_EXCEPTION(std::runtime_error(str));
29 }
30 
throw_logic_error(const char * str)31 inline void throw_logic_error(const char * str)
32 {
33     BOOST_THROW_EXCEPTION(std::logic_error(str));
34 }
35 
throw_invalid_argument(const char * str)36 inline void throw_invalid_argument(const char * str)
37 {
38     BOOST_THROW_EXCEPTION(std::invalid_argument(str));
39 }
40 
throw_length_error(const char * str)41 inline void throw_length_error(const char * str)
42 {
43     BOOST_THROW_EXCEPTION(std::length_error(str));
44 }
45 
throw_out_of_range(const char * str)46 inline void throw_out_of_range(const char * str)
47 {
48     BOOST_THROW_EXCEPTION(std::out_of_range(str));
49 }
50 
51 #else
52 
53 inline void throw_runtime_error(const char * str)
54 {
55     BOOST_GEOMETRY_INDEX_ASSERT(!"runtime_error thrown", str);
56     std::abort();
57 }
58 
59 inline void throw_logic_error(const char * str)
60 {
61     BOOST_GEOMETRY_INDEX_ASSERT(!"logic_error thrown", str);
62     std::abort();
63 }
64 
65 inline void throw_invalid_argument(const char * str)
66 {
67     BOOST_GEOMETRY_INDEX_ASSERT(!"invalid_argument thrown", str);
68     std::abort();
69 }
70 
71 inline void throw_length_error(const char * str)
72 {
73     BOOST_GEOMETRY_INDEX_ASSERT(!"length_error thrown", str);
74     std::abort();
75 }
76 
77 inline void throw_out_of_range(const char * str)
78 {
79     BOOST_GEOMETRY_INDEX_ASSERT(!"out_of_range thrown", str);
80     std::abort();
81 }
82 
83 #endif
84 
85 }}}} // namespace boost::geometry::index::detail
86 
87 #endif // BOOST_GEOMETRY_INDEX_DETAIL_EXCEPTION_HPP
88