名稱空間
變體
操作

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

來自 cppreference.com
 
 
記憶體管理庫
(僅作說明*)
未初始化記憶體演算法
(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] 參閱

[靜態]
在已分配的儲存中構造一個物件
(函式模板) [編輯]
[靜態]
銷燬儲存在已分配儲存中的物件
(函式模板) [編輯]