Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/c++/v1/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_STDEXCEPT
0011 #define _LIBCPP_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 #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
0045 #  include <__cxx03/stdexcept>
0046 #else
0047 #  include <__config>
0048 #  include <__exception/exception.h>
0049 #  include <__fwd/string.h>
0050 #  include <__verbose_abort>
0051 
0052 #  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0053 #    pragma GCC system_header
0054 #  endif
0055 
0056 _LIBCPP_BEGIN_NAMESPACE_STD
0057 
0058 #  ifndef _LIBCPP_ABI_VCRUNTIME
0059 class _LIBCPP_HIDDEN __libcpp_refstring {
0060   const char* __imp_;
0061 
0062   bool __uses_refcount() const;
0063 
0064 public:
0065   explicit __libcpp_refstring(const char* __msg);
0066   __libcpp_refstring(const __libcpp_refstring& __s) _NOEXCEPT;
0067   __libcpp_refstring& operator=(const __libcpp_refstring& __s) _NOEXCEPT;
0068   ~__libcpp_refstring();
0069 
0070   _LIBCPP_HIDE_FROM_ABI const char* c_str() const _NOEXCEPT { return __imp_; }
0071 };
0072 #  endif // !_LIBCPP_ABI_VCRUNTIME
0073 
0074 _LIBCPP_END_NAMESPACE_STD
0075 
0076 namespace std // purposefully not using versioning namespace
0077 {
0078 
0079 class _LIBCPP_EXPORTED_FROM_ABI logic_error : public exception {
0080 #  ifndef _LIBCPP_ABI_VCRUNTIME
0081 
0082 private:
0083   std::__libcpp_refstring __imp_;
0084 
0085 public:
0086   explicit logic_error(const string&);
0087   explicit logic_error(const char*);
0088 
0089   logic_error(const logic_error&) _NOEXCEPT;
0090   logic_error& operator=(const logic_error&) _NOEXCEPT;
0091 
0092   ~logic_error() _NOEXCEPT override;
0093 
0094   const char* what() const _NOEXCEPT override;
0095 #  else
0096 
0097 public:
0098   explicit logic_error(const std::string&); // Symbol uses versioned std::string
0099   _LIBCPP_HIDE_FROM_ABI explicit logic_error(const char* __s) : exception(__s) {}
0100 #  endif
0101 };
0102 
0103 class _LIBCPP_EXPORTED_FROM_ABI runtime_error : public exception {
0104 #  ifndef _LIBCPP_ABI_VCRUNTIME
0105 
0106 private:
0107   std::__libcpp_refstring __imp_;
0108 
0109 public:
0110   explicit runtime_error(const string&);
0111   explicit runtime_error(const char*);
0112 
0113   runtime_error(const runtime_error&) _NOEXCEPT;
0114   runtime_error& operator=(const runtime_error&) _NOEXCEPT;
0115 
0116   ~runtime_error() _NOEXCEPT override;
0117 
0118   const char* what() const _NOEXCEPT override;
0119 #  else
0120 
0121 public:
0122   explicit runtime_error(const std::string&); // Symbol uses versioned std::string
0123   _LIBCPP_HIDE_FROM_ABI explicit runtime_error(const char* __s) : exception(__s) {}
0124 #  endif // _LIBCPP_ABI_VCRUNTIME
0125 };
0126 
0127 class _LIBCPP_EXPORTED_FROM_ABI domain_error : public logic_error {
0128 public:
0129   _LIBCPP_HIDE_FROM_ABI explicit domain_error(const string& __s) : logic_error(__s) {}
0130   _LIBCPP_HIDE_FROM_ABI explicit domain_error(const char* __s) : logic_error(__s) {}
0131 
0132 #  ifndef _LIBCPP_ABI_VCRUNTIME
0133   _LIBCPP_HIDE_FROM_ABI domain_error(const domain_error&) _NOEXCEPT            = default;
0134   _LIBCPP_HIDE_FROM_ABI domain_error& operator=(const domain_error&) _NOEXCEPT = default;
0135   ~domain_error() _NOEXCEPT override;
0136 #  endif
0137 };
0138 
0139 class _LIBCPP_EXPORTED_FROM_ABI invalid_argument : public logic_error {
0140 public:
0141   _LIBCPP_HIDE_FROM_ABI explicit invalid_argument(const string& __s) : logic_error(__s) {}
0142   _LIBCPP_HIDE_FROM_ABI explicit invalid_argument(const char* __s) : logic_error(__s) {}
0143 
0144 #  ifndef _LIBCPP_ABI_VCRUNTIME
0145   _LIBCPP_HIDE_FROM_ABI invalid_argument(const invalid_argument&) _NOEXCEPT            = default;
0146   _LIBCPP_HIDE_FROM_ABI invalid_argument& operator=(const invalid_argument&) _NOEXCEPT = default;
0147   ~invalid_argument() _NOEXCEPT override;
0148 #  endif
0149 };
0150 
0151 class _LIBCPP_EXPORTED_FROM_ABI length_error : public logic_error {
0152 public:
0153   _LIBCPP_HIDE_FROM_ABI explicit length_error(const string& __s) : logic_error(__s) {}
0154   _LIBCPP_HIDE_FROM_ABI explicit length_error(const char* __s) : logic_error(__s) {}
0155 #  ifndef _LIBCPP_ABI_VCRUNTIME
0156   _LIBCPP_HIDE_FROM_ABI length_error(const length_error&) _NOEXCEPT            = default;
0157   _LIBCPP_HIDE_FROM_ABI length_error& operator=(const length_error&) _NOEXCEPT = default;
0158   ~length_error() _NOEXCEPT override;
0159 #  endif
0160 };
0161 
0162 class _LIBCPP_EXPORTED_FROM_ABI out_of_range : public logic_error {
0163 public:
0164   _LIBCPP_HIDE_FROM_ABI explicit out_of_range(const string& __s) : logic_error(__s) {}
0165   _LIBCPP_HIDE_FROM_ABI explicit out_of_range(const char* __s) : logic_error(__s) {}
0166 
0167 #  ifndef _LIBCPP_ABI_VCRUNTIME
0168   _LIBCPP_HIDE_FROM_ABI out_of_range(const out_of_range&) _NOEXCEPT            = default;
0169   _LIBCPP_HIDE_FROM_ABI out_of_range& operator=(const out_of_range&) _NOEXCEPT = default;
0170   ~out_of_range() _NOEXCEPT override;
0171 #  endif
0172 };
0173 
0174 class _LIBCPP_EXPORTED_FROM_ABI range_error : public runtime_error {
0175 public:
0176   _LIBCPP_HIDE_FROM_ABI explicit range_error(const string& __s) : runtime_error(__s) {}
0177   _LIBCPP_HIDE_FROM_ABI explicit range_error(const char* __s) : runtime_error(__s) {}
0178 
0179 #  ifndef _LIBCPP_ABI_VCRUNTIME
0180   _LIBCPP_HIDE_FROM_ABI range_error(const range_error&) _NOEXCEPT            = default;
0181   _LIBCPP_HIDE_FROM_ABI range_error& operator=(const range_error&) _NOEXCEPT = default;
0182   ~range_error() _NOEXCEPT override;
0183 #  endif
0184 };
0185 
0186 class _LIBCPP_EXPORTED_FROM_ABI overflow_error : public runtime_error {
0187 public:
0188   _LIBCPP_HIDE_FROM_ABI explicit overflow_error(const string& __s) : runtime_error(__s) {}
0189   _LIBCPP_HIDE_FROM_ABI explicit overflow_error(const char* __s) : runtime_error(__s) {}
0190 
0191 #  ifndef _LIBCPP_ABI_VCRUNTIME
0192   _LIBCPP_HIDE_FROM_ABI overflow_error(const overflow_error&) _NOEXCEPT            = default;
0193   _LIBCPP_HIDE_FROM_ABI overflow_error& operator=(const overflow_error&) _NOEXCEPT = default;
0194   ~overflow_error() _NOEXCEPT override;
0195 #  endif
0196 };
0197 
0198 class _LIBCPP_EXPORTED_FROM_ABI underflow_error : public runtime_error {
0199 public:
0200   _LIBCPP_HIDE_FROM_ABI explicit underflow_error(const string& __s) : runtime_error(__s) {}
0201   _LIBCPP_HIDE_FROM_ABI explicit underflow_error(const char* __s) : runtime_error(__s) {}
0202 
0203 #  ifndef _LIBCPP_ABI_VCRUNTIME
0204   _LIBCPP_HIDE_FROM_ABI underflow_error(const underflow_error&) _NOEXCEPT            = default;
0205   _LIBCPP_HIDE_FROM_ABI underflow_error& operator=(const underflow_error&) _NOEXCEPT = default;
0206   ~underflow_error() _NOEXCEPT override;
0207 #  endif
0208 };
0209 
0210 } // namespace std
0211 
0212 _LIBCPP_BEGIN_NAMESPACE_STD
0213 
0214 // in the dylib
0215 [[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_runtime_error(const char*);
0216 
0217 [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_logic_error(const char* __msg) {
0218 #  if _LIBCPP_HAS_EXCEPTIONS
0219   throw logic_error(__msg);
0220 #  else
0221   _LIBCPP_VERBOSE_ABORT("logic_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
0222 #  endif
0223 }
0224 
0225 [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_domain_error(const char* __msg) {
0226 #  if _LIBCPP_HAS_EXCEPTIONS
0227   throw domain_error(__msg);
0228 #  else
0229   _LIBCPP_VERBOSE_ABORT("domain_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
0230 #  endif
0231 }
0232 
0233 [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_invalid_argument(const char* __msg) {
0234 #  if _LIBCPP_HAS_EXCEPTIONS
0235   throw invalid_argument(__msg);
0236 #  else
0237   _LIBCPP_VERBOSE_ABORT("invalid_argument was thrown in -fno-exceptions mode with message \"%s\"", __msg);
0238 #  endif
0239 }
0240 
0241 [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_length_error(const char* __msg) {
0242 #  if _LIBCPP_HAS_EXCEPTIONS
0243   throw length_error(__msg);
0244 #  else
0245   _LIBCPP_VERBOSE_ABORT("length_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
0246 #  endif
0247 }
0248 
0249 [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range(const char* __msg) {
0250 #  if _LIBCPP_HAS_EXCEPTIONS
0251   throw out_of_range(__msg);
0252 #  else
0253   _LIBCPP_VERBOSE_ABORT("out_of_range was thrown in -fno-exceptions mode with message \"%s\"", __msg);
0254 #  endif
0255 }
0256 
0257 [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_range_error(const char* __msg) {
0258 #  if _LIBCPP_HAS_EXCEPTIONS
0259   throw range_error(__msg);
0260 #  else
0261   _LIBCPP_VERBOSE_ABORT("range_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
0262 #  endif
0263 }
0264 
0265 [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_overflow_error(const char* __msg) {
0266 #  if _LIBCPP_HAS_EXCEPTIONS
0267   throw overflow_error(__msg);
0268 #  else
0269   _LIBCPP_VERBOSE_ABORT("overflow_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
0270 #  endif
0271 }
0272 
0273 [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_underflow_error(const char* __msg) {
0274 #  if _LIBCPP_HAS_EXCEPTIONS
0275   throw underflow_error(__msg);
0276 #  else
0277   _LIBCPP_VERBOSE_ABORT("underflow_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
0278 #  endif
0279 }
0280 
0281 _LIBCPP_END_NAMESPACE_STD
0282 
0283 #  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
0284 #    include <cstddef>
0285 #    include <cstdlib>
0286 #    include <exception>
0287 #    include <iosfwd>
0288 #    include <new>
0289 #  endif
0290 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
0291 
0292 #endif // _LIBCPP_STDEXCEPT