命名空间
变体
操作

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);

[编辑] 缺陷报告

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

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

[编辑] 参见

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