标准库头文件 <new>
来自 cppreference.com
此头文件是 动态内存管理 库的一部分,特别提供了 低级内存管理 功能。
类 | ||
当内存分配失败时抛出的异常 (类) | ||
(C++11) |
在使用无效长度分配数组时抛出的异常 (类) | |
(C++17) |
用于将对齐传递到支持对齐的分配和释放函数的类型 (枚举) | |
类型 | ||
新处理程序的函数指针类型 (typedef) | ||
标签 | ||
用于选择非抛出分配函数的标签 (标签) | ||
用于选择 operator delete 的销毁删除重载的标签 (标签) | ||
常量 | ||
最小偏移量,以避免错误共享 最大偏移量,以促进真实共享 (常量) | ||
函数 | ||
分配函数 (函数) | ||
释放函数 (函数) | ||
(C++11) |
获取当前的 new 处理程序 (函数) | |
注册新的处理程序 (函数) | ||
(C++17) |
指针优化屏障 (函数模板) |
[编辑] 概要
namespace std { // storage allocation errors class bad_alloc; class bad_array_new_length; struct destroying_delete_t { explicit destroying_delete_t() = default; }; inline constexpr destroying_delete_t destroying_delete{}; // global operator new control 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; // pointer optimization barrier template<class T> constexpr T* launder(T* p) noexcept; // hardware interference size inline constexpr size_t hardware_destructive_interference_size = /* implementation-defined */; inline constexpr size_t hardware_constructive_interference_size = /* implementation-defined */; } // storage allocation and deallocation 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; constexpr void* operator new (std::size_t size, void* ptr) noexcept; constexpr void* operator new[](std::size_t size, void* ptr) noexcept; void operator delete (void* ptr, void*) noexcept; void operator delete[](void* ptr, void*) noexcept;