名稱空間
變體
操作

std::allocation_result

來自 cppreference.com
< cpp‎ | 記憶體
 
 
記憶體管理庫
(僅作說明*)
未初始化記憶體演算法
(C++17)
(C++17)
(C++17)
受約束的未初始化
記憶體演算法
C 庫

分配器
allocation_result
(C++23)
記憶體資源
垃圾回收支援
(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*)
顯式生命週期管理
 
定義於標頭檔案 <memory>
template< class Pointer, class SizeType = std::size_t >
struct allocation_result;
(C++23 起)

allocation_result 特化由相應 Allocator 型別的 allocate_at_least 成員函式(例如 std::allocator::allocate_at_least)和 std::allocator_traits::allocate_at_least 返回。

allocation_result 的每個特化都沒有基類或除 ptrcount 之外的宣告成員,因此它適用於聚合初始化結構化繫結

目錄

[編輯] 模板引數

指標 - 通常是 std::allocator_traits<Alloc>::pointer,其中 Alloc 是一個 Allocator 型別
SizeType - 通常是 std::allocator_traits<Alloc>::size_type,其中 Alloc 是一個 Allocator 型別

[編輯] 資料成員

成員名稱 (Member name) 定義
ptr
型別為 Pointer 的指標,通常用於由 allocate_at_least 分配的儲存中第一個元素的地址
(公有成員物件)
count
型別為 SizeType 的值,通常用於由 allocate_at_least 分配的儲存中元素的實際數量
(公有成員物件)

[編輯] 註解

PointerSizeType 預設是指向物件型別的指標和 std::make_unsigned_t<std::ptrdiff_t>(幾乎總是與 std::size_t 相同)。

特性測試 標準 特性
__cpp_lib_allocate_at_least 202302L (C++23) Allocator 介面中的大小反饋

[編輯] 示例

[編輯] 參閱

分配至少與請求大小一樣大的未初始化儲存
(std::allocator<T> 的公共成員函式) [編輯]
[static] (C++23)
透過分配器分配至少請求大小的儲存空間
(std::allocator_traits<Alloc> 的公共靜態成員函式) [編輯]