File indexing completed on 2026-05-03 08:13:57
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _LIBCPP___NEW_EXCEPTIONS_H
0010 #define _LIBCPP___NEW_EXCEPTIONS_H
0011
0012 #include <__config>
0013 #include <__exception/exception.h>
0014 #include <__verbose_abort>
0015
0016 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0017 # pragma GCC system_header
0018 #endif
0019
0020
0021 namespace std {
0022 #if !defined(_LIBCPP_ABI_VCRUNTIME)
0023
0024 class _LIBCPP_EXPORTED_FROM_ABI bad_alloc : public exception {
0025 public:
0026 bad_alloc() _NOEXCEPT;
0027 _LIBCPP_HIDE_FROM_ABI bad_alloc(const bad_alloc&) _NOEXCEPT = default;
0028 _LIBCPP_HIDE_FROM_ABI bad_alloc& operator=(const bad_alloc&) _NOEXCEPT = default;
0029 ~bad_alloc() _NOEXCEPT override;
0030 const char* what() const _NOEXCEPT override;
0031 };
0032
0033 class _LIBCPP_EXPORTED_FROM_ABI bad_array_new_length : public bad_alloc {
0034 public:
0035 bad_array_new_length() _NOEXCEPT;
0036 _LIBCPP_HIDE_FROM_ABI bad_array_new_length(const bad_array_new_length&) _NOEXCEPT = default;
0037 _LIBCPP_HIDE_FROM_ABI bad_array_new_length& operator=(const bad_array_new_length&) _NOEXCEPT = default;
0038 ~bad_array_new_length() _NOEXCEPT override;
0039 const char* what() const _NOEXCEPT override;
0040 };
0041
0042 #elif defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0
0043
0044
0045
0046 class bad_alloc : public exception {
0047 public:
0048 bad_alloc() noexcept : exception("bad allocation") {}
0049
0050 private:
0051 friend class bad_array_new_length;
0052
0053 bad_alloc(char const* const __message) noexcept : exception(__message) {}
0054 };
0055
0056 class bad_array_new_length : public bad_alloc {
0057 public:
0058 bad_array_new_length() noexcept : bad_alloc("bad array new length") {}
0059 };
0060
0061 #endif
0062
0063 [[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_bad_alloc();
0064
0065 [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_array_new_length() {
0066 #if _LIBCPP_HAS_EXCEPTIONS
0067 throw bad_array_new_length();
0068 #else
0069 _LIBCPP_VERBOSE_ABORT("bad_array_new_length was thrown in -fno-exceptions mode");
0070 #endif
0071 }
0072 }
0073
0074 #endif