Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
Louis Dionne | 9bd9388 | 2021-11-17 16:25:01 -0500 | [diff] [blame] | 2 | //===----------------------------------------------------------------------===// |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3 | // |
Chandler Carruth | d201210 | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | // See https://llvm.org/LICENSE.txt for license information. |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef _LIBCPP_STDEXCEPT |
| 11 | #define _LIBCPP_STDEXCEPT |
| 12 | |
| 13 | /* |
| 14 | stdexcept synopsis |
| 15 | |
| 16 | namespace std |
| 17 | { |
| 18 | |
| 19 | class logic_error; |
| 20 | class domain_error; |
| 21 | class invalid_argument; |
| 22 | class length_error; |
| 23 | class out_of_range; |
| 24 | class runtime_error; |
| 25 | class range_error; |
| 26 | class overflow_error; |
| 27 | class underflow_error; |
| 28 | |
| 29 | for each class xxx_error: |
| 30 | |
| 31 | class xxx_error : public exception // at least indirectly |
| 32 | { |
| 33 | public: |
| 34 | explicit xxx_error(const string& what_arg); |
Howard Hinnant | 1f098bc | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 35 | explicit xxx_error(const char* what_arg); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 36 | |
Howard Hinnant | 1f098bc | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 37 | virtual const char* what() const noexcept // returns what_arg |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | } // std |
| 41 | |
| 42 | */ |
| 43 | |
Louis Dionne | b4fce35 | 2022-03-25 12:55:36 -0400 | [diff] [blame] | 44 | #include <__assert> // all public C++ headers provide the assertion handler |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 45 | #include <__config> |
Arthur O'Dwyer | 65077c0 | 2022-01-07 09:45:05 -0500 | [diff] [blame] | 46 | #include <cstdlib> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 47 | #include <exception> |
| 48 | #include <iosfwd> // for string forward decl |
| 49 | |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 50 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Arthur O'Dwyer | 6eeaa00 | 2022-02-01 20:16:40 -0500 | [diff] [blame] | 51 | # pragma GCC system_header |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 52 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 53 | |
Joerg Sonnenberger | a47c2e7 | 2014-04-30 19:54:11 +0000 | [diff] [blame] | 54 | _LIBCPP_BEGIN_NAMESPACE_STD |
Eric Fiselier | 1e65516 | 2016-10-25 19:33:14 +0000 | [diff] [blame] | 55 | |
Eric Fiselier | c6e689b | 2019-03-06 20:31:57 +0000 | [diff] [blame] | 56 | #ifndef _LIBCPP_ABI_VCRUNTIME |
Eric Fiselier | 1e65516 | 2016-10-25 19:33:14 +0000 | [diff] [blame] | 57 | class _LIBCPP_HIDDEN __libcpp_refstring |
| 58 | { |
| 59 | const char* __imp_; |
| 60 | |
| 61 | bool __uses_refcount() const; |
| 62 | public: |
Eric Fiselier | c5ea1ae | 2017-06-01 02:29:37 +0000 | [diff] [blame] | 63 | explicit __libcpp_refstring(const char* __msg); |
| 64 | __libcpp_refstring(const __libcpp_refstring& __s) _NOEXCEPT; |
| 65 | __libcpp_refstring& operator=(const __libcpp_refstring& __s) _NOEXCEPT; |
Eric Fiselier | 1e65516 | 2016-10-25 19:33:14 +0000 | [diff] [blame] | 66 | ~__libcpp_refstring(); |
| 67 | |
| 68 | const char* c_str() const _NOEXCEPT {return __imp_;} |
Joerg Sonnenberger | a47c2e7 | 2014-04-30 19:54:11 +0000 | [diff] [blame] | 69 | }; |
Eric Fiselier | c6e689b | 2019-03-06 20:31:57 +0000 | [diff] [blame] | 70 | #endif // !_LIBCPP_ABI_VCRUNTIME |
Eric Fiselier | 1e65516 | 2016-10-25 19:33:14 +0000 | [diff] [blame] | 71 | |
Joerg Sonnenberger | a47c2e7 | 2014-04-30 19:54:11 +0000 | [diff] [blame] | 72 | _LIBCPP_END_NAMESPACE_STD |
Joerg Sonnenberger | a47c2e7 | 2014-04-30 19:54:11 +0000 | [diff] [blame] | 73 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 74 | namespace std // purposefully not using versioning namespace |
| 75 | { |
| 76 | |
| 77 | class _LIBCPP_EXCEPTION_ABI logic_error |
| 78 | : public exception |
| 79 | { |
Eric Fiselier | c6e689b | 2019-03-06 20:31:57 +0000 | [diff] [blame] | 80 | #ifndef _LIBCPP_ABI_VCRUNTIME |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 81 | private: |
Joerg Sonnenberger | a47c2e7 | 2014-04-30 19:54:11 +0000 | [diff] [blame] | 82 | _VSTD::__libcpp_refstring __imp_; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 83 | public: |
| 84 | explicit logic_error(const string&); |
| 85 | explicit logic_error(const char*); |
| 86 | |
Howard Hinnant | 1f098bc | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 87 | logic_error(const logic_error&) _NOEXCEPT; |
| 88 | logic_error& operator=(const logic_error&) _NOEXCEPT; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 89 | |
Nikolas Klauser | aa3a6cd | 2022-08-24 02:14:29 +0200 | [diff] [blame^] | 90 | ~logic_error() _NOEXCEPT override; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 91 | |
Nikolas Klauser | aa3a6cd | 2022-08-24 02:14:29 +0200 | [diff] [blame^] | 92 | const char* what() const _NOEXCEPT override; |
Eric Fiselier | c6e689b | 2019-03-06 20:31:57 +0000 | [diff] [blame] | 93 | #else |
| 94 | public: |
| 95 | explicit logic_error(const _VSTD::string&); // Symbol uses versioned std::string |
| 96 | _LIBCPP_INLINE_VISIBILITY explicit logic_error(const char* __s) : exception(__s) {} |
| 97 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 98 | }; |
| 99 | |
| 100 | class _LIBCPP_EXCEPTION_ABI runtime_error |
| 101 | : public exception |
| 102 | { |
Eric Fiselier | c6e689b | 2019-03-06 20:31:57 +0000 | [diff] [blame] | 103 | #ifndef _LIBCPP_ABI_VCRUNTIME |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 104 | private: |
Joerg Sonnenberger | a47c2e7 | 2014-04-30 19:54:11 +0000 | [diff] [blame] | 105 | _VSTD::__libcpp_refstring __imp_; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 106 | public: |
| 107 | explicit runtime_error(const string&); |
| 108 | explicit runtime_error(const char*); |
| 109 | |
Howard Hinnant | 1f098bc | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 110 | runtime_error(const runtime_error&) _NOEXCEPT; |
| 111 | runtime_error& operator=(const runtime_error&) _NOEXCEPT; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 112 | |
Nikolas Klauser | aa3a6cd | 2022-08-24 02:14:29 +0200 | [diff] [blame^] | 113 | ~runtime_error() _NOEXCEPT override; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 114 | |
Nikolas Klauser | aa3a6cd | 2022-08-24 02:14:29 +0200 | [diff] [blame^] | 115 | const char* what() const _NOEXCEPT override; |
Eric Fiselier | c6e689b | 2019-03-06 20:31:57 +0000 | [diff] [blame] | 116 | #else |
| 117 | public: |
| 118 | explicit runtime_error(const _VSTD::string&); // Symbol uses versioned std::string |
| 119 | _LIBCPP_INLINE_VISIBILITY explicit runtime_error(const char* __s) : exception(__s) {} |
| 120 | #endif // _LIBCPP_ABI_VCRUNTIME |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 121 | }; |
| 122 | |
| 123 | class _LIBCPP_EXCEPTION_ABI domain_error |
| 124 | : public logic_error |
| 125 | { |
| 126 | public: |
| 127 | _LIBCPP_INLINE_VISIBILITY explicit domain_error(const string& __s) : logic_error(__s) {} |
| 128 | _LIBCPP_INLINE_VISIBILITY explicit domain_error(const char* __s) : logic_error(__s) {} |
| 129 | |
Eric Fiselier | c6e689b | 2019-03-06 20:31:57 +0000 | [diff] [blame] | 130 | #ifndef _LIBCPP_ABI_VCRUNTIME |
Dimitry Andric | 47269ce | 2020-03-13 19:36:26 +0100 | [diff] [blame] | 131 | domain_error(const domain_error&) _NOEXCEPT = default; |
Nikolas Klauser | aa3a6cd | 2022-08-24 02:14:29 +0200 | [diff] [blame^] | 132 | ~domain_error() _NOEXCEPT override; |
Eric Fiselier | c6e689b | 2019-03-06 20:31:57 +0000 | [diff] [blame] | 133 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 134 | }; |
| 135 | |
| 136 | class _LIBCPP_EXCEPTION_ABI invalid_argument |
| 137 | : public logic_error |
| 138 | { |
| 139 | public: |
| 140 | _LIBCPP_INLINE_VISIBILITY explicit invalid_argument(const string& __s) : logic_error(__s) {} |
| 141 | _LIBCPP_INLINE_VISIBILITY explicit invalid_argument(const char* __s) : logic_error(__s) {} |
| 142 | |
Eric Fiselier | c6e689b | 2019-03-06 20:31:57 +0000 | [diff] [blame] | 143 | #ifndef _LIBCPP_ABI_VCRUNTIME |
Dimitry Andric | 47269ce | 2020-03-13 19:36:26 +0100 | [diff] [blame] | 144 | invalid_argument(const invalid_argument&) _NOEXCEPT = default; |
Nikolas Klauser | aa3a6cd | 2022-08-24 02:14:29 +0200 | [diff] [blame^] | 145 | ~invalid_argument() _NOEXCEPT override; |
Eric Fiselier | c6e689b | 2019-03-06 20:31:57 +0000 | [diff] [blame] | 146 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 147 | }; |
| 148 | |
| 149 | class _LIBCPP_EXCEPTION_ABI length_error |
| 150 | : public logic_error |
| 151 | { |
| 152 | public: |
| 153 | _LIBCPP_INLINE_VISIBILITY explicit length_error(const string& __s) : logic_error(__s) {} |
| 154 | _LIBCPP_INLINE_VISIBILITY explicit length_error(const char* __s) : logic_error(__s) {} |
Eric Fiselier | c6e689b | 2019-03-06 20:31:57 +0000 | [diff] [blame] | 155 | #ifndef _LIBCPP_ABI_VCRUNTIME |
Dimitry Andric | 47269ce | 2020-03-13 19:36:26 +0100 | [diff] [blame] | 156 | length_error(const length_error&) _NOEXCEPT = default; |
Nikolas Klauser | aa3a6cd | 2022-08-24 02:14:29 +0200 | [diff] [blame^] | 157 | ~length_error() _NOEXCEPT override; |
Eric Fiselier | c6e689b | 2019-03-06 20:31:57 +0000 | [diff] [blame] | 158 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 159 | }; |
| 160 | |
| 161 | class _LIBCPP_EXCEPTION_ABI out_of_range |
| 162 | : public logic_error |
| 163 | { |
| 164 | public: |
| 165 | _LIBCPP_INLINE_VISIBILITY explicit out_of_range(const string& __s) : logic_error(__s) {} |
| 166 | _LIBCPP_INLINE_VISIBILITY explicit out_of_range(const char* __s) : logic_error(__s) {} |
| 167 | |
Eric Fiselier | c6e689b | 2019-03-06 20:31:57 +0000 | [diff] [blame] | 168 | #ifndef _LIBCPP_ABI_VCRUNTIME |
Dimitry Andric | 47269ce | 2020-03-13 19:36:26 +0100 | [diff] [blame] | 169 | out_of_range(const out_of_range&) _NOEXCEPT = default; |
Nikolas Klauser | aa3a6cd | 2022-08-24 02:14:29 +0200 | [diff] [blame^] | 170 | ~out_of_range() _NOEXCEPT override; |
Eric Fiselier | c6e689b | 2019-03-06 20:31:57 +0000 | [diff] [blame] | 171 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 172 | }; |
| 173 | |
| 174 | class _LIBCPP_EXCEPTION_ABI range_error |
| 175 | : public runtime_error |
| 176 | { |
| 177 | public: |
| 178 | _LIBCPP_INLINE_VISIBILITY explicit range_error(const string& __s) : runtime_error(__s) {} |
| 179 | _LIBCPP_INLINE_VISIBILITY explicit range_error(const char* __s) : runtime_error(__s) {} |
| 180 | |
Eric Fiselier | c6e689b | 2019-03-06 20:31:57 +0000 | [diff] [blame] | 181 | #ifndef _LIBCPP_ABI_VCRUNTIME |
Dimitry Andric | 47269ce | 2020-03-13 19:36:26 +0100 | [diff] [blame] | 182 | range_error(const range_error&) _NOEXCEPT = default; |
Nikolas Klauser | aa3a6cd | 2022-08-24 02:14:29 +0200 | [diff] [blame^] | 183 | ~range_error() _NOEXCEPT override; |
Eric Fiselier | c6e689b | 2019-03-06 20:31:57 +0000 | [diff] [blame] | 184 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 185 | }; |
| 186 | |
| 187 | class _LIBCPP_EXCEPTION_ABI overflow_error |
| 188 | : public runtime_error |
| 189 | { |
| 190 | public: |
| 191 | _LIBCPP_INLINE_VISIBILITY explicit overflow_error(const string& __s) : runtime_error(__s) {} |
| 192 | _LIBCPP_INLINE_VISIBILITY explicit overflow_error(const char* __s) : runtime_error(__s) {} |
| 193 | |
Eric Fiselier | c6e689b | 2019-03-06 20:31:57 +0000 | [diff] [blame] | 194 | #ifndef _LIBCPP_ABI_VCRUNTIME |
Dimitry Andric | 47269ce | 2020-03-13 19:36:26 +0100 | [diff] [blame] | 195 | overflow_error(const overflow_error&) _NOEXCEPT = default; |
Nikolas Klauser | aa3a6cd | 2022-08-24 02:14:29 +0200 | [diff] [blame^] | 196 | ~overflow_error() _NOEXCEPT override; |
Eric Fiselier | c6e689b | 2019-03-06 20:31:57 +0000 | [diff] [blame] | 197 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 198 | }; |
| 199 | |
| 200 | class _LIBCPP_EXCEPTION_ABI underflow_error |
| 201 | : public runtime_error |
| 202 | { |
| 203 | public: |
| 204 | _LIBCPP_INLINE_VISIBILITY explicit underflow_error(const string& __s) : runtime_error(__s) {} |
| 205 | _LIBCPP_INLINE_VISIBILITY explicit underflow_error(const char* __s) : runtime_error(__s) {} |
| 206 | |
Eric Fiselier | c6e689b | 2019-03-06 20:31:57 +0000 | [diff] [blame] | 207 | #ifndef _LIBCPP_ABI_VCRUNTIME |
Dimitry Andric | 47269ce | 2020-03-13 19:36:26 +0100 | [diff] [blame] | 208 | underflow_error(const underflow_error&) _NOEXCEPT = default; |
Nikolas Klauser | aa3a6cd | 2022-08-24 02:14:29 +0200 | [diff] [blame^] | 209 | ~underflow_error() _NOEXCEPT override; |
Eric Fiselier | c6e689b | 2019-03-06 20:31:57 +0000 | [diff] [blame] | 210 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 211 | }; |
| 212 | |
Nikolas Klauser | d26407a | 2021-12-02 14:12:51 +0100 | [diff] [blame] | 213 | } // namespace std |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 214 | |
Marshall Clow | 8fea161 | 2016-08-25 15:09:01 +0000 | [diff] [blame] | 215 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 216 | |
| 217 | // in the dylib |
| 218 | _LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_runtime_error(const char*); |
| 219 | |
Louis Dionne | 16fe295 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 220 | _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 8fea161 | 2016-08-25 15:09:01 +0000 | [diff] [blame] | 221 | void __throw_logic_error(const char*__msg) |
| 222 | { |
| 223 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 224 | throw logic_error(__msg); |
| 225 | #else |
Eric Fiselier | 6003c77 | 2016-12-23 23:37:52 +0000 | [diff] [blame] | 226 | ((void)__msg); |
Louis Dionne | 44bcff9 | 2018-08-03 22:36:53 +0000 | [diff] [blame] | 227 | _VSTD::abort(); |
Marshall Clow | 8fea161 | 2016-08-25 15:09:01 +0000 | [diff] [blame] | 228 | #endif |
| 229 | } |
| 230 | |
Louis Dionne | 16fe295 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 231 | _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 8fea161 | 2016-08-25 15:09:01 +0000 | [diff] [blame] | 232 | void __throw_domain_error(const char*__msg) |
| 233 | { |
| 234 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 235 | throw domain_error(__msg); |
| 236 | #else |
Eric Fiselier | 6003c77 | 2016-12-23 23:37:52 +0000 | [diff] [blame] | 237 | ((void)__msg); |
Louis Dionne | 44bcff9 | 2018-08-03 22:36:53 +0000 | [diff] [blame] | 238 | _VSTD::abort(); |
Marshall Clow | 8fea161 | 2016-08-25 15:09:01 +0000 | [diff] [blame] | 239 | #endif |
| 240 | } |
| 241 | |
Louis Dionne | 16fe295 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 242 | _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 8fea161 | 2016-08-25 15:09:01 +0000 | [diff] [blame] | 243 | void __throw_invalid_argument(const char*__msg) |
| 244 | { |
| 245 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 246 | throw invalid_argument(__msg); |
| 247 | #else |
Eric Fiselier | 6003c77 | 2016-12-23 23:37:52 +0000 | [diff] [blame] | 248 | ((void)__msg); |
Louis Dionne | 44bcff9 | 2018-08-03 22:36:53 +0000 | [diff] [blame] | 249 | _VSTD::abort(); |
Marshall Clow | 8fea161 | 2016-08-25 15:09:01 +0000 | [diff] [blame] | 250 | #endif |
| 251 | } |
| 252 | |
Louis Dionne | 16fe295 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 253 | _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 8fea161 | 2016-08-25 15:09:01 +0000 | [diff] [blame] | 254 | void __throw_length_error(const char*__msg) |
| 255 | { |
| 256 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 257 | throw length_error(__msg); |
| 258 | #else |
Eric Fiselier | 6003c77 | 2016-12-23 23:37:52 +0000 | [diff] [blame] | 259 | ((void)__msg); |
Louis Dionne | 44bcff9 | 2018-08-03 22:36:53 +0000 | [diff] [blame] | 260 | _VSTD::abort(); |
Marshall Clow | 8fea161 | 2016-08-25 15:09:01 +0000 | [diff] [blame] | 261 | #endif |
| 262 | } |
| 263 | |
Louis Dionne | 16fe295 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 264 | _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 8fea161 | 2016-08-25 15:09:01 +0000 | [diff] [blame] | 265 | void __throw_out_of_range(const char*__msg) |
| 266 | { |
| 267 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 268 | throw out_of_range(__msg); |
| 269 | #else |
Eric Fiselier | 6003c77 | 2016-12-23 23:37:52 +0000 | [diff] [blame] | 270 | ((void)__msg); |
Louis Dionne | 44bcff9 | 2018-08-03 22:36:53 +0000 | [diff] [blame] | 271 | _VSTD::abort(); |
Marshall Clow | 8fea161 | 2016-08-25 15:09:01 +0000 | [diff] [blame] | 272 | #endif |
| 273 | } |
| 274 | |
Louis Dionne | 16fe295 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 275 | _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 8fea161 | 2016-08-25 15:09:01 +0000 | [diff] [blame] | 276 | void __throw_range_error(const char*__msg) |
| 277 | { |
| 278 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 279 | throw range_error(__msg); |
| 280 | #else |
Eric Fiselier | 6003c77 | 2016-12-23 23:37:52 +0000 | [diff] [blame] | 281 | ((void)__msg); |
Louis Dionne | 44bcff9 | 2018-08-03 22:36:53 +0000 | [diff] [blame] | 282 | _VSTD::abort(); |
Marshall Clow | 8fea161 | 2016-08-25 15:09:01 +0000 | [diff] [blame] | 283 | #endif |
| 284 | } |
| 285 | |
Louis Dionne | 16fe295 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 286 | _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 8fea161 | 2016-08-25 15:09:01 +0000 | [diff] [blame] | 287 | void __throw_overflow_error(const char*__msg) |
| 288 | { |
| 289 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 290 | throw overflow_error(__msg); |
| 291 | #else |
Eric Fiselier | 6003c77 | 2016-12-23 23:37:52 +0000 | [diff] [blame] | 292 | ((void)__msg); |
| 293 | _VSTD::abort(); |
Marshall Clow | 8fea161 | 2016-08-25 15:09:01 +0000 | [diff] [blame] | 294 | #endif |
| 295 | } |
| 296 | |
Louis Dionne | 16fe295 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 297 | _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY |
Marshall Clow | 8fea161 | 2016-08-25 15:09:01 +0000 | [diff] [blame] | 298 | void __throw_underflow_error(const char*__msg) |
| 299 | { |
| 300 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 301 | throw underflow_error(__msg); |
| 302 | #else |
Eric Fiselier | 6003c77 | 2016-12-23 23:37:52 +0000 | [diff] [blame] | 303 | ((void)__msg); |
| 304 | _VSTD::abort(); |
Marshall Clow | 8fea161 | 2016-08-25 15:09:01 +0000 | [diff] [blame] | 305 | #endif |
| 306 | } |
| 307 | |
| 308 | _LIBCPP_END_NAMESPACE_STD |
| 309 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 310 | #endif // _LIBCPP_STDEXCEPT |