Warning, file /include/boost/container/throw_exception.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_CONTAINER_THROW_EXCEPTION_HPP
0012 #define BOOST_CONTAINER_THROW_EXCEPTION_HPP
0013
0014 #ifndef BOOST_CONFIG_HPP
0015 # include <boost/config.hpp>
0016 #endif
0017
0018 #if defined(BOOST_HAS_PRAGMA_ONCE)
0019 # pragma once
0020 #endif
0021
0022 #include <boost/container/detail/config_begin.hpp>
0023 #include <boost/container/detail/workaround.hpp>
0024
0025 #ifndef BOOST_NO_EXCEPTIONS
0026 #include <exception> //for std exception base
0027
0028 # if defined(BOOST_CONTAINER_USE_STD_EXCEPTIONS)
0029 #include <stdexcept> //for std::out_of_range, std::length_error, std::logic_error, std::runtime_error
0030 #include <string> //for implicit std::string conversion
0031 #include <new> //for std::bad_alloc
0032
0033 namespace boost {
0034 namespace container {
0035
0036 typedef std::bad_alloc bad_alloc_t;
0037 typedef std::out_of_range out_of_range_t;
0038 typedef std::length_error length_error_t;
0039 typedef std::logic_error logic_error_t;
0040 typedef std::runtime_error runtime_error_t;
0041
0042 }}
0043
0044 # else
0045
0046 namespace boost {
0047 namespace container {
0048
0049 class BOOST_SYMBOL_VISIBLE exception
0050 : public ::std::exception
0051 {
0052 typedef ::std::exception std_exception_t;
0053
0054 public:
0055
0056
0057 explicit exception(const char *msg)
0058 : std_exception_t(), m_msg(msg)
0059 {}
0060
0061 virtual const char *what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE
0062 { return m_msg ? m_msg : "unknown boost::container exception"; }
0063
0064 private:
0065 const char *m_msg;
0066 };
0067
0068 class BOOST_SYMBOL_VISIBLE bad_alloc
0069 : public exception
0070 {
0071 public:
0072 bad_alloc()
0073 : exception("boost::container::bad_alloc thrown")
0074 {}
0075 };
0076
0077 typedef bad_alloc bad_alloc_t;
0078
0079 class BOOST_SYMBOL_VISIBLE out_of_range
0080 : public exception
0081 {
0082 public:
0083 explicit out_of_range(const char *msg)
0084 : exception(msg)
0085 {}
0086 };
0087
0088 typedef out_of_range out_of_range_t;
0089
0090 class BOOST_SYMBOL_VISIBLE length_error
0091 : public exception
0092 {
0093 public:
0094 explicit length_error(const char *msg)
0095 : exception(msg)
0096 {}
0097 };
0098
0099 typedef length_error length_error_t;
0100
0101 class BOOST_SYMBOL_VISIBLE logic_error
0102 : public exception
0103 {
0104 public:
0105 explicit logic_error(const char *msg)
0106 : exception(msg)
0107 {}
0108 };
0109
0110 typedef logic_error logic_error_t;
0111
0112 class BOOST_SYMBOL_VISIBLE runtime_error
0113 : public exception
0114 {
0115 public:
0116 explicit runtime_error(const char *msg)
0117 : exception(msg)
0118 {}
0119 };
0120
0121 typedef runtime_error runtime_error_t;
0122
0123 }
0124 }
0125
0126 # endif
0127 #else
0128 #include <boost/assert.hpp>
0129 #include <cstdlib> //for std::abort
0130 #endif
0131
0132 namespace boost {
0133 namespace container {
0134
0135 #if defined(BOOST_CONTAINER_USER_DEFINED_THROW_CALLBACKS)
0136
0137
0138 BOOST_NORETURN void throw_bad_alloc();
0139
0140 BOOST_NORETURN void throw_out_of_range(const char* str);
0141
0142 BOOST_NORETURN void throw_length_error(const char* str);
0143
0144 BOOST_NORETURN void throw_logic_error(const char* str);
0145
0146 BOOST_NORETURN void throw_runtime_error(const char* str);
0147
0148 #elif defined(BOOST_NO_EXCEPTIONS)
0149
0150 BOOST_NORETURN inline void throw_bad_alloc()
0151 {
0152 BOOST_ASSERT(!"boost::container bad_alloc thrown");
0153 std::abort();
0154 }
0155
0156 BOOST_NORETURN inline void throw_out_of_range(const char* str)
0157 {
0158 boost::container::ignore(str);
0159 BOOST_ASSERT_MSG(!"boost::container out_of_range thrown", str);
0160 std::abort();
0161 }
0162
0163 BOOST_NORETURN inline void throw_length_error(const char* str)
0164 {
0165 boost::container::ignore(str);
0166 BOOST_ASSERT_MSG(!"boost::container length_error thrown", str);
0167 std::abort();
0168 }
0169
0170 BOOST_NORETURN inline void throw_logic_error(const char* str)
0171 {
0172 boost::container::ignore(str);
0173 BOOST_ASSERT_MSG(!"boost::container logic_error thrown", str);
0174 std::abort();
0175 }
0176
0177 BOOST_NORETURN inline void throw_runtime_error(const char* str)
0178 {
0179 boost::container::ignore(str);
0180 BOOST_ASSERT_MSG(!"boost::container runtime_error thrown", str);
0181 std::abort();
0182 }
0183
0184 #else
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201 BOOST_NORETURN inline void throw_bad_alloc()
0202 {
0203 throw bad_alloc_t();
0204 }
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221 BOOST_NORETURN inline void throw_out_of_range(const char* str)
0222 {
0223 throw out_of_range_t(str);
0224 }
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242 BOOST_NORETURN inline void throw_length_error(const char* str)
0243 {
0244 throw length_error_t(str);
0245 }
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264 BOOST_NORETURN inline void throw_logic_error(const char* str)
0265 {
0266 throw logic_error_t(str);
0267 }
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284 BOOST_NORETURN inline void throw_runtime_error(const char* str)
0285 {
0286 throw runtime_error_t(str);
0287 }
0288
0289 #endif
0290
0291 }}
0292
0293 #include <boost/container/detail/config_end.hpp>
0294
0295 #endif