2 //===----------------------------- new ------------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
25 bad_alloc(const bad_alloc&) noexcept;
26 bad_alloc& operator=(const bad_alloc&) noexcept;
27 virtual const char* what() const noexcept;
31 extern const nothrow_t nothrow;
32 typedef void (*new_handler)();
33 new_handler set_new_handler(new_handler new_p) noexcept;
34 new_handler get_new_handler() noexcept;
38 void* operator new(std::size_t size); // replaceable
39 void* operator new(std::size_t size, const std::nothrow_t&) noexcept; // replaceable
40 void operator delete(void* ptr) noexcept; // replaceable
41 void operator delete(void* ptr, const std::nothrow_t&) noexcept; // replaceable
43 void* operator new[](std::size_t size); // replaceable
44 void* operator new[](std::size_t size, const std::nothrow_t&) noexcept; // replaceable
45 void operator delete[](void* ptr) noexcept; // replaceable
46 void operator delete[](void* ptr, const std::nothrow_t&) noexcept; // replaceable
48 void* operator new (std::size_t size, void* ptr) noexcept;
49 void* operator new[](std::size_t size, void* ptr) noexcept;
50 void operator delete (void* ptr, void*) noexcept;
51 void operator delete[](void* ptr, void*) noexcept;
59 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
60 #pragma GCC system_header
63 namespace std // purposefully not using versioning namespace
66 class _LIBCPP_EXCEPTION_ABI bad_alloc
70 bad_alloc() _NOEXCEPT;
71 virtual ~bad_alloc() _NOEXCEPT;
72 virtual const char* what() const _NOEXCEPT;
75 class _LIBCPP_EXCEPTION_ABI bad_array_new_length
79 bad_array_new_length() _NOEXCEPT;
80 virtual ~bad_array_new_length() _NOEXCEPT;
81 virtual const char* what() const _NOEXCEPT;
84 void __throw_bad_alloc(); // not in C++ spec
86 struct _LIBCPP_TYPE_VIS nothrow_t {};
87 extern _LIBCPP_FUNC_VIS const nothrow_t nothrow;
88 typedef void (*new_handler)();
89 _LIBCPP_FUNC_VIS new_handler set_new_handler(new_handler) _NOEXCEPT;
90 _LIBCPP_FUNC_VIS new_handler get_new_handler() _NOEXCEPT;
94 _LIBCPP_FUNC_VIS void* operator new(std::size_t __sz)
95 #if !__has_feature(cxx_noexcept)
99 _LIBCPP_FUNC_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
100 _LIBCPP_FUNC_VIS void operator delete(void* __p) _NOEXCEPT;
101 _LIBCPP_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT;
103 _LIBCPP_FUNC_VIS void* operator new[](std::size_t __sz)
104 #if !__has_feature(cxx_noexcept)
105 throw(std::bad_alloc)
108 _LIBCPP_FUNC_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
109 _LIBCPP_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT;
110 _LIBCPP_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT;
112 _LIBCPP_INLINE_VISIBILITY inline void* operator new (std::size_t, void* __p) _NOEXCEPT {return __p;}
113 _LIBCPP_INLINE_VISIBILITY inline void* operator new[](std::size_t, void* __p) _NOEXCEPT {return __p;}
114 _LIBCPP_INLINE_VISIBILITY inline void operator delete (void*, void*) _NOEXCEPT {}
115 _LIBCPP_INLINE_VISIBILITY inline void operator delete[](void*, void*) _NOEXCEPT {}
117 #endif // _LIBCPP_NEW