[IRBuilder] Refactor FMF interface (#121657)
[llvm-project.git] / libcxx / include / new
blob4d72ec27675c9e4e2939394174bf1d84a5baba64
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP_NEW
11 #define _LIBCPP_NEW
14     new synopsis
16 namespace std
19 class bad_alloc
20     : public exception
22 public:
23     bad_alloc() noexcept;
24     bad_alloc(const bad_alloc&) noexcept;
25     bad_alloc& operator=(const bad_alloc&) noexcept;
26     virtual const char* what() const noexcept;
29 class bad_array_new_length : public bad_alloc // C++14
31 public:
32     bad_array_new_length() noexcept;
35 enum class align_val_t : size_t {}; // C++17
37 struct destroying_delete_t { // C++20
38   explicit destroying_delete_t() = default;
40 inline constexpr destroying_delete_t destroying_delete{}; // C++20
42 struct nothrow_t { explicit nothrow_t() = default; };
43 extern const nothrow_t nothrow;
44 typedef void (*new_handler)();
45 new_handler set_new_handler(new_handler new_p) noexcept;
46 new_handler get_new_handler() noexcept;
48 // 21.6.4, pointer optimization barrier
49 template <class T> [[nodiscard]] constexpr T* launder(T* p) noexcept;   // C++17, nodiscard since C++20
50 }  // std
52 void* operator new(std::size_t size);                                   // replaceable, nodiscard in C++20
53 void* operator new(std::size_t size, std::align_val_t alignment);       // replaceable, C++17, nodiscard in C++20
54 void* operator new(std::size_t size, const std::nothrow_t&) noexcept;   // replaceable, nodiscard in C++20
55 void* operator new(std::size_t size, std::align_val_t alignment,
56                    const std::nothrow_t&) noexcept;                     // replaceable, C++17, nodiscard in C++20
57 void  operator delete(void* ptr) noexcept;                              // replaceable
58 void  operator delete(void* ptr, std::size_t size) noexcept;            // replaceable, C++14
59 void  operator delete(void* ptr, std::align_val_t alignment) noexcept;  // replaceable, C++17
60 void  operator delete(void* ptr, std::size_t size,
61                       std::align_val_t alignment) noexcept;             // replaceable, C++17
62 void  operator delete(void* ptr, const std::nothrow_t&) noexcept;       // replaceable
63 void  operator delete(void* ptr, std:align_val_t alignment,
64                       const std::nothrow_t&) noexcept;                  // replaceable, C++17
66 void* operator new[](std::size_t size);                                 // replaceable, nodiscard in C++20
67 void* operator new[](std::size_t size,
68                      std::align_val_t alignment) noexcept;              // replaceable, C++17, nodiscard in C++20
69 void* operator new[](std::size_t size, const std::nothrow_t&) noexcept; // replaceable, nodiscard in C++20
70 void* operator new[](std::size_t size, std::align_val_t alignment,
71                      const std::nothrow_t&) noexcept;                   // replaceable, C++17, nodiscard in C++20
72 void  operator delete[](void* ptr) noexcept;                            // replaceable
73 void  operator delete[](void* ptr, std::size_t size) noexcept;          // replaceable, C++14
74 void  operator delete[](void* ptr,
75                         std::align_val_t alignment) noexcept;           // replaceable, C++17
76 void  operator delete[](void* ptr, std::size_t size,
77                         std::align_val_t alignment) noexcept;           // replaceable, C++17
78 void  operator delete[](void* ptr, const std::nothrow_t&) noexcept;     // replaceable
79 void  operator delete[](void* ptr, std::align_val_t alignment,
80                         const std::nothrow_t&) noexcept;                // replaceable, C++17
82 void* operator new  (std::size_t size, void* ptr) noexcept;             // nodiscard in C++20, constexpr since C++26
83 void* operator new[](std::size_t size, void* ptr) noexcept;             // nodiscard in C++20, constexpr since C++26
84 void  operator delete  (void* ptr, void*) noexcept;
85 void  operator delete[](void* ptr, void*) noexcept;
89 #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
90 #  include <__cxx03/new>
91 #else
92 #  include <__config>
93 #  include <__new/align_val_t.h>
94 #  include <__new/allocate.h>
95 #  include <__new/exceptions.h>
96 #  include <__new/global_new_delete.h>
97 #  include <__new/new_handler.h>
98 #  include <__new/nothrow_t.h>
99 #  include <__new/placement_new_delete.h>
101 #  if _LIBCPP_STD_VER >= 17
102 #    include <__new/interference_size.h>
103 #    include <__new/launder.h>
104 #  endif
106 #  if _LIBCPP_STD_VER >= 20
107 #    include <__new/destroying_delete_t.h>
108 #  endif
110 // feature-test macros
111 #  include <version>
113 #  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
114 #    pragma GCC system_header
115 #  endif
117 #  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
118 #    include <cstddef>
119 #    include <cstdlib>
120 #    include <type_traits>
121 #  endif
122 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
124 #endif // _LIBCPP_NEW