Warning, /include/c++/v1/__cxx03/stdexcept is written in an unsupported language. File is not indexed.
0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009
0010 #ifndef _LIBCPP___CXX03_STDEXCEPT
0011 #define _LIBCPP___CXX03_STDEXCEPT
0012
0013 /*
0014 stdexcept synopsis
0015
0016 namespace std
0017 {
0018
0019 class logic_error;
0020 class domain_error;
0021 class invalid_argument;
0022 class length_error;
0023 class out_of_range;
0024 class runtime_error;
0025 class range_error;
0026 class overflow_error;
0027 class underflow_error;
0028
0029 for each class xxx_error:
0030
0031 class xxx_error : public exception // at least indirectly
0032 {
0033 public:
0034 explicit xxx_error(const string& what_arg);
0035 explicit xxx_error(const char* what_arg);
0036
0037 virtual const char* what() const noexcept // returns what_arg
0038 };
0039
0040 } // std
0041
0042 */
0043
0044 #include <__cxx03/__config>
0045 #include <__cxx03/__exception/exception.h>
0046 #include <__cxx03/__fwd/string.h>
0047 #include <__cxx03/__verbose_abort>
0048
0049 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0050 # pragma GCC system_header
0051 #endif
0052
0053 _LIBCPP_BEGIN_NAMESPACE_STD
0054
0055 #ifndef _LIBCPP_ABI_VCRUNTIME
0056 class _LIBCPP_HIDDEN __libcpp_refstring {
0057 const char* __imp_;
0058
0059 bool __uses_refcount() const;
0060
0061 public:
0062 explicit __libcpp_refstring(const char* __msg);
0063 __libcpp_refstring(const __libcpp_refstring& __s) _NOEXCEPT;
0064 __libcpp_refstring& operator=(const __libcpp_refstring& __s) _NOEXCEPT;
0065 ~__libcpp_refstring();
0066
0067 _LIBCPP_HIDE_FROM_ABI const char* c_str() const _NOEXCEPT { return __imp_; }
0068 };
0069 #endif // !_LIBCPP_ABI_VCRUNTIME
0070
0071 _LIBCPP_END_NAMESPACE_STD
0072
0073 namespace std // purposefully not using versioning namespace
0074 {
0075
0076 class _LIBCPP_EXPORTED_FROM_ABI logic_error : public exception {
0077 #ifndef _LIBCPP_ABI_VCRUNTIME
0078
0079 private:
0080 std::__libcpp_refstring __imp_;
0081
0082 public:
0083 explicit logic_error(const string&);
0084 explicit logic_error(const char*);
0085
0086 logic_error(const logic_error&) _NOEXCEPT;
0087 logic_error& operator=(const logic_error&) _NOEXCEPT;
0088
0089 ~logic_error() _NOEXCEPT override;
0090
0091 const char* what() const _NOEXCEPT override;
0092 #else
0093
0094 public:
0095 explicit logic_error(const std::string&); // Symbol uses versioned std::string
0096 _LIBCPP_HIDE_FROM_ABI explicit logic_error(const char* __s) : exception(__s) {}
0097 #endif
0098 };
0099
0100 class _LIBCPP_EXPORTED_FROM_ABI runtime_error : public exception {
0101 #ifndef _LIBCPP_ABI_VCRUNTIME
0102
0103 private:
0104 std::__libcpp_refstring __imp_;
0105
0106 public:
0107 explicit runtime_error(const string&);
0108 explicit runtime_error(const char*);
0109
0110 runtime_error(const runtime_error&) _NOEXCEPT;
0111 runtime_error& operator=(const runtime_error&) _NOEXCEPT;
0112
0113 ~runtime_error() _NOEXCEPT override;
0114
0115 const char* what() const _NOEXCEPT override;
0116 #else
0117
0118 public:
0119 explicit runtime_error(const std::string&); // Symbol uses versioned std::string
0120 _LIBCPP_HIDE_FROM_ABI explicit runtime_error(const char* __s) : exception(__s) {}
0121 #endif // _LIBCPP_ABI_VCRUNTIME
0122 };
0123
0124 class _LIBCPP_EXPORTED_FROM_ABI domain_error : public logic_error {
0125 public:
0126 _LIBCPP_HIDE_FROM_ABI explicit domain_error(const string& __s) : logic_error(__s) {}
0127 _LIBCPP_HIDE_FROM_ABI explicit domain_error(const char* __s) : logic_error(__s) {}
0128
0129 #ifndef _LIBCPP_ABI_VCRUNTIME
0130 _LIBCPP_HIDE_FROM_ABI domain_error(const domain_error&) _NOEXCEPT = default;
0131 _LIBCPP_HIDE_FROM_ABI domain_error& operator=(const domain_error&) _NOEXCEPT = default;
0132 ~domain_error() _NOEXCEPT override;
0133 #endif
0134 };
0135
0136 class _LIBCPP_EXPORTED_FROM_ABI invalid_argument : public logic_error {
0137 public:
0138 _LIBCPP_HIDE_FROM_ABI explicit invalid_argument(const string& __s) : logic_error(__s) {}
0139 _LIBCPP_HIDE_FROM_ABI explicit invalid_argument(const char* __s) : logic_error(__s) {}
0140
0141 #ifndef _LIBCPP_ABI_VCRUNTIME
0142 _LIBCPP_HIDE_FROM_ABI invalid_argument(const invalid_argument&) _NOEXCEPT = default;
0143 _LIBCPP_HIDE_FROM_ABI invalid_argument& operator=(const invalid_argument&) _NOEXCEPT = default;
0144 ~invalid_argument() _NOEXCEPT override;
0145 #endif
0146 };
0147
0148 class _LIBCPP_EXPORTED_FROM_ABI length_error : public logic_error {
0149 public:
0150 _LIBCPP_HIDE_FROM_ABI explicit length_error(const string& __s) : logic_error(__s) {}
0151 _LIBCPP_HIDE_FROM_ABI explicit length_error(const char* __s) : logic_error(__s) {}
0152 #ifndef _LIBCPP_ABI_VCRUNTIME
0153 _LIBCPP_HIDE_FROM_ABI length_error(const length_error&) _NOEXCEPT = default;
0154 _LIBCPP_HIDE_FROM_ABI length_error& operator=(const length_error&) _NOEXCEPT = default;
0155 ~length_error() _NOEXCEPT override;
0156 #endif
0157 };
0158
0159 class _LIBCPP_EXPORTED_FROM_ABI out_of_range : public logic_error {
0160 public:
0161 _LIBCPP_HIDE_FROM_ABI explicit out_of_range(const string& __s) : logic_error(__s) {}
0162 _LIBCPP_HIDE_FROM_ABI explicit out_of_range(const char* __s) : logic_error(__s) {}
0163
0164 #ifndef _LIBCPP_ABI_VCRUNTIME
0165 _LIBCPP_HIDE_FROM_ABI out_of_range(const out_of_range&) _NOEXCEPT = default;
0166 _LIBCPP_HIDE_FROM_ABI out_of_range& operator=(const out_of_range&) _NOEXCEPT = default;
0167 ~out_of_range() _NOEXCEPT override;
0168 #endif
0169 };
0170
0171 class _LIBCPP_EXPORTED_FROM_ABI range_error : public runtime_error {
0172 public:
0173 _LIBCPP_HIDE_FROM_ABI explicit range_error(const string& __s) : runtime_error(__s) {}
0174 _LIBCPP_HIDE_FROM_ABI explicit range_error(const char* __s) : runtime_error(__s) {}
0175
0176 #ifndef _LIBCPP_ABI_VCRUNTIME
0177 _LIBCPP_HIDE_FROM_ABI range_error(const range_error&) _NOEXCEPT = default;
0178 _LIBCPP_HIDE_FROM_ABI range_error& operator=(const range_error&) _NOEXCEPT = default;
0179 ~range_error() _NOEXCEPT override;
0180 #endif
0181 };
0182
0183 class _LIBCPP_EXPORTED_FROM_ABI overflow_error : public runtime_error {
0184 public:
0185 _LIBCPP_HIDE_FROM_ABI explicit overflow_error(const string& __s) : runtime_error(__s) {}
0186 _LIBCPP_HIDE_FROM_ABI explicit overflow_error(const char* __s) : runtime_error(__s) {}
0187
0188 #ifndef _LIBCPP_ABI_VCRUNTIME
0189 _LIBCPP_HIDE_FROM_ABI overflow_error(const overflow_error&) _NOEXCEPT = default;
0190 _LIBCPP_HIDE_FROM_ABI overflow_error& operator=(const overflow_error&) _NOEXCEPT = default;
0191 ~overflow_error() _NOEXCEPT override;
0192 #endif
0193 };
0194
0195 class _LIBCPP_EXPORTED_FROM_ABI underflow_error : public runtime_error {
0196 public:
0197 _LIBCPP_HIDE_FROM_ABI explicit underflow_error(const string& __s) : runtime_error(__s) {}
0198 _LIBCPP_HIDE_FROM_ABI explicit underflow_error(const char* __s) : runtime_error(__s) {}
0199
0200 #ifndef _LIBCPP_ABI_VCRUNTIME
0201 _LIBCPP_HIDE_FROM_ABI underflow_error(const underflow_error&) _NOEXCEPT = default;
0202 _LIBCPP_HIDE_FROM_ABI underflow_error& operator=(const underflow_error&) _NOEXCEPT = default;
0203 ~underflow_error() _NOEXCEPT override;
0204 #endif
0205 };
0206
0207 } // namespace std
0208
0209 _LIBCPP_BEGIN_NAMESPACE_STD
0210
0211 // in the dylib
0212 _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_runtime_error(const char*);
0213
0214 _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_logic_error(const char* __msg) {
0215 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
0216 throw logic_error(__msg);
0217 #else
0218 _LIBCPP_VERBOSE_ABORT("logic_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
0219 #endif
0220 }
0221
0222 _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_domain_error(const char* __msg) {
0223 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
0224 throw domain_error(__msg);
0225 #else
0226 _LIBCPP_VERBOSE_ABORT("domain_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
0227 #endif
0228 }
0229
0230 _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_invalid_argument(const char* __msg) {
0231 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
0232 throw invalid_argument(__msg);
0233 #else
0234 _LIBCPP_VERBOSE_ABORT("invalid_argument was thrown in -fno-exceptions mode with message \"%s\"", __msg);
0235 #endif
0236 }
0237
0238 _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_length_error(const char* __msg) {
0239 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
0240 throw length_error(__msg);
0241 #else
0242 _LIBCPP_VERBOSE_ABORT("length_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
0243 #endif
0244 }
0245
0246 _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range(const char* __msg) {
0247 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
0248 throw out_of_range(__msg);
0249 #else
0250 _LIBCPP_VERBOSE_ABORT("out_of_range was thrown in -fno-exceptions mode with message \"%s\"", __msg);
0251 #endif
0252 }
0253
0254 _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_range_error(const char* __msg) {
0255 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
0256 throw range_error(__msg);
0257 #else
0258 _LIBCPP_VERBOSE_ABORT("range_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
0259 #endif
0260 }
0261
0262 _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_overflow_error(const char* __msg) {
0263 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
0264 throw overflow_error(__msg);
0265 #else
0266 _LIBCPP_VERBOSE_ABORT("overflow_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
0267 #endif
0268 }
0269
0270 _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_underflow_error(const char* __msg) {
0271 #ifndef _LIBCPP_HAS_NO_EXCEPTIONS
0272 throw underflow_error(__msg);
0273 #else
0274 _LIBCPP_VERBOSE_ABORT("underflow_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
0275 #endif
0276 }
0277
0278 _LIBCPP_END_NAMESPACE_STD
0279
0280 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
0281 # include <__cxx03/cstdlib>
0282 # include <__cxx03/exception>
0283 # include <__cxx03/iosfwd>
0284 #endif
0285
0286 #endif // _LIBCPP___CXX03_STDEXCEPT