File indexing completed on 2026-05-03 08:13:26
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _LIBCPP___CXX03___EXCEPTION_EXCEPTION_H
0010 #define _LIBCPP___CXX03___EXCEPTION_EXCEPTION_H
0011
0012 #include <__cxx03/__config>
0013
0014
0015
0016 #if defined(_LIBCPP_ABI_VCRUNTIME)
0017 # include <__cxx03/vcruntime_exception.h>
0018 #endif
0019
0020 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0021 # pragma GCC system_header
0022 #endif
0023
0024 namespace std {
0025
0026 #if defined(_LIBCPP_ABI_VCRUNTIME) && (!defined(_HAS_EXCEPTIONS) || _HAS_EXCEPTIONS != 0)
0027
0028
0029 #elif defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0
0030
0031
0032
0033
0034
0035
0036
0037 struct __std_exception_data {
0038 char const* _What;
0039 bool _DoFree;
0040 };
0041
0042 class exception {
0043 public:
0044 exception() _NOEXCEPT : __data_() {}
0045
0046 explicit exception(char const* __message) _NOEXCEPT : __data_() {
0047 __data_._What = __message;
0048 __data_._DoFree = true;
0049 }
0050
0051 exception(exception const&) _NOEXCEPT {}
0052
0053 exception& operator=(exception const&) _NOEXCEPT { return *this; }
0054
0055 virtual ~exception() _NOEXCEPT {}
0056
0057 virtual char const* what() const _NOEXCEPT { return __data_._What ? __data_._What : "Unknown exception"; }
0058
0059 private:
0060 __std_exception_data __data_;
0061 };
0062
0063 class bad_exception : public exception {
0064 public:
0065 bad_exception() _NOEXCEPT : exception("bad exception") {}
0066 };
0067
0068 #else
0069
0070
0071
0072 class _LIBCPP_EXPORTED_FROM_ABI exception {
0073 public:
0074 _LIBCPP_HIDE_FROM_ABI exception() _NOEXCEPT {}
0075 _LIBCPP_HIDE_FROM_ABI exception(const exception&) _NOEXCEPT = default;
0076 _LIBCPP_HIDE_FROM_ABI exception& operator=(const exception&) _NOEXCEPT = default;
0077
0078 virtual ~exception() _NOEXCEPT;
0079 virtual const char* what() const _NOEXCEPT;
0080 };
0081
0082 class _LIBCPP_EXPORTED_FROM_ABI bad_exception : public exception {
0083 public:
0084 _LIBCPP_HIDE_FROM_ABI bad_exception() _NOEXCEPT {}
0085 _LIBCPP_HIDE_FROM_ABI bad_exception(const bad_exception&) _NOEXCEPT = default;
0086 _LIBCPP_HIDE_FROM_ABI bad_exception& operator=(const bad_exception&) _NOEXCEPT = default;
0087 ~bad_exception() _NOEXCEPT override;
0088 const char* what() const _NOEXCEPT override;
0089 };
0090 #endif
0091
0092 }
0093
0094 #endif