Namespaces
Variants

std::allocator<T>:: destroy

From cppreference.net
Memory management library
( exposition only* )
Allocators
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Memory resources
Uninitialized storage (until C++20)
( until C++20* )
( until C++20* )
( until C++20* )

Garbage collector support (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
定义于头文件 <memory>
void destroy ( pointer p ) ;
(1) (C++11 前)
template < class U >
void destroy ( U * p ) ;
(2) (C++11 起)
(C++17 中弃用)
(C++20 中移除)

调用由 p 指向的对象的析构函数。

1) 调用 p - > ~T ( )
2) 调用 p - > ~U ( )

目录

参数

p - 指向即将被销毁对象的指针

返回值

(无)

缺陷报告

下列行为变更缺陷报告被追溯应用于先前发布的C++标准。

缺陷报告 应用于 发布时行为 正确行为
LWG 400 C++98 p 被强制转换为 T* ,即 p 的类型 移除了冗余的强制转换

参见

[static]
销毁分配存储中的对象
(函数模板)