标准库头文件 <new>

来自cppreference.com
< cpp‎ | header
 
 
 

此头文件是动态内存管理库的一部分,特别提供低层内存管理特性。

函数
分配函数
(函数)
解分配函数
(函数)
获得当前的 new 处理函数
(函数)
注册一个 new 处理函数
(函数)
(C++17)
指针优化屏障
(函数模板)
内存分配失败时抛出的异常
(类)
在分配有非法长度的数组时抛出的异常
(类)
用于选择不抛出分配函数的标签类型
(类)
用于向带对齐分配及解分配函数传递对齐值的类型
(类)
用于鉴别 operator delete 的销毁删除重载的标签类型
(类)
类型
new 处理函数的函数指针类型
(typedef)
对象
用于选择不抛出分配函数nothrow_t 类型对象
(常量)
避免假共享的最小偏移
促使真共享的最大偏移
(常量)

概要

namespace std {
  class bad_alloc;
  class bad_array_new_length;
  struct destroying_delete_t {
    explicit destroying_delete_t() = default;
  };
  inline constexpr destroying_delete_t destroying_delete{};
  enum class align_val_t : size_t {};
  struct nothrow_t { explicit nothrow_t() = default; };
  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;
  inline constexpr size_t
    hardware_destructive_interference_size = /* 由实现定义 */ ;
  inline constexpr size_t
    hardware_constructive_interference_size = /* 由实现定义 */ ;
}
 
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;