命名空间
变体
操作

std::scoped_allocator_adaptor<OuterAlloc,InnerAlloc...>::outermost, outermost-construct, outermost-destroy

来自 cppreference.cn
 
 
内存管理库
(仅作说明*)
未初始化内存算法
(C++17)
(C++17)
(C++17)
受约束的未初始化
内存算法
C 库

分配器
内存资源
垃圾回收支持
(C++11)(直到 C++23)
(C++11)(直到 C++23)
(C++11)(直到 C++23)
(C++11)(直到 C++23)
(C++11)(直到 C++23)
(C++11)(直到 C++23)
未初始化存储
(直到 C++20*)
(直到 C++20*)
显式生命周期管理
 
 
template< class Alloc >
/* unspecified */ /*outermost*/( Alloc&& alloc = *this );
(1) (仅作说明*)
template< class T, class... Args >
void /*outermost-construct*/( T* p, Args&&... args );
(2) (仅作说明*)
template< class T >
void /*outermost-destroy*/( T* p );
(3) (仅作说明*)

这些仅用于说明的辅助成员函数模板用于成员函数 construct()destroy()

1) 获取 alloc 的最外层分配器。
  • 如果表达式 alloc.outer_allocator() 有效,则返回 outermost (alloc.outer_allocator())
  • 否则,返回 alloc
2,3) 使用 *this 的最外层分配器构造或销毁对象。
给定类型 std::allocator_traits<std::remove_reference_t<decltype(outermost ())>> 作为 outermost_traits
2) 等价于 outermost_traits::construct(outermost (), p, std::forward<Args>(args)...);
3) 等价于 outermost_traits::destroy(outermost (), p);

[edit] 缺陷报告

下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。

缺陷报告 应用于 发布时的行为 正确的行为
LWG 3116 C++11 outermost 的递归条件是 “alloc
具有成员函数 outer_allocator()
更改为 “表达式
alloc.outer_allocator() 有效”

[edit] 参阅

[静态]
在已分配的存储中构造一个对象
(函数模板) [编辑]
[静态]
销毁存储在已分配存储中的对象
(函数模板) [编辑]