Namespaces
Variants
Views
Actions

Standard library header <new>

From cppreference.com
< cpp‎ | header

This header is part of the dynamic memory management library, in particular provides low level memory management features.

Contents

Functions
allocation functions
(function) [edit]
deallocation functions
(function) [edit]
obtains the current new handler
(function) [edit]
registers a new handler
(function) [edit]
(C++17)
pointer optimization barrier
(function template) [edit]
Classes
exception thrown when memory allocation fails
(class) [edit]
exception thrown on allocation of array with invalid length
(class) [edit]
tag type used to select an non-throwing allocation function
(class) [edit]
type used to pass alignment to alignment-aware allocation and deallocation functions
(class) [edit]
Types
function pointer type of the new handler
(typedef) [edit]
Objects
an object of type nothrow_t used to select an non-throwing allocation function
(constant) [edit]
min offset to avoid false sharing
max offset to promote true sharing
(constant) [edit]


[edit] Synopsis

namespace std {
  class bad_alloc;
  class bad_array_new_length;
  enum class align_val_t : size_t {};
  struct nothrow_t {};
  extern const nothrow_t nothrow;
  using new_handler = void (*)();
  new_handler get_new_handler() noexcept;
  new_handler set_new_handler(new_handler new_p) noexcept;
  template <class T> constexpr T* launder(T* p) noexcept;
  static constexpr size_t
    hardware_destructive_interference_size = /*implementation-defined*/ ;
  static constexpr size_t
    hardware_constructive_interference_size = /*implementation-defined*/ ;
}
 
void* operator new(std::size_t size);
void* operator new(std::size_t size, std::align_val_t alignment);
void* operator new(std::size_t size, const std::nothrow_t&) noexcept;
void* operator new(std::size_t size, std::align_val_t alignment,
                   const std::nothrow_t&) noexcept;
void operator delete(void* ptr) noexcept;
void operator delete(void* ptr, std::size_t size) noexcept;
void operator delete(void* ptr, std::align_val_t alignment) noexcept;
void operator delete(void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
void operator delete(void* ptr, const std::nothrow_t&) noexcept;
void operator delete(void* ptr, std::align_val_t alignment,
                     const std::nothrow_t&) noexcept;
void* operator new[](std::size_t size);
void* operator new[](std::size_t size, std::align_val_t alignment);
void* operator new[](std::size_t size, const std::nothrow_t&) noexcept;
void* operator new[](std::size_t size,
                     std::align_val_t alignment,
                     const std::nothrow_t&) noexcept;
void operator delete[](void* ptr) noexcept;
void operator delete[](void* ptr, std::size_t size) noexcept;
void operator delete[](void* ptr, std::align_val_t alignment) noexcept;
void operator delete[](void* ptr, std::size_t size, std::align_val_t alignment) noexcept;
void operator delete[](void* ptr, const std::nothrow_t&) noexcept;
void operator delete[](void* ptr, std::align_val_t alignment,
                       const std::nothrow_t&) noexcept;
void* operator new (std::size_t size, void* ptr) noexcept;
void* operator new[](std::size_t size, void* ptr) noexcept;
void operator delete (void* ptr, void*) noexcept;
void operator delete[](void* ptr, void*) noexcept;