std::allocator_traits<Alloc>::destroy
来自 cppreference.cn
< cpp | memory | allocator traits
定义于头文件 <memory> |
||
template< class T > static void destroy( Alloc& a, T* p ); |
(自 C++11 起) (constexpr 自 C++20 起) |
|
调用 p 指向对象的析构函数。如果可能,通过调用 a.destroy(p) 来实现。如果不可能(例如,Alloc
没有成员函数 destroy()
),则调用 *p 的析构函数,直接如同 p->~T()(直到 C++20)std::destroy_at(p)(自 C++20 起)。
内容 |
[编辑] 参数
a | - | 用于销毁的分配器 |
p | - | 指向被销毁对象的指针 |
[编辑] 返回值
(无)
[编辑] 注解
因为此函数提供了自动回退到直接调用析构函数的功能,所以成员函数 destroy()
自 C++11 起是可选的 Allocator 要求。
[编辑] 示例
本节尚不完整 原因:没有示例 |
[编辑] 参见
(直到 C++20) |
在已分配存储中析构对象 ( std::allocator<T> 的公有成员函数) |