名稱空間
變體
操作

std::uninitialized_construct_using_allocator

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

分配器
uninitialized_construct_using_allocator
(C++20) 
記憶體資源
垃圾回收支援
(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 T, class Alloc, class... Args >

constexpr T* uninitialized_construct_using_allocator( T* p,
                                                      const Alloc& alloc,

                                                      Args&&... args );
(C++20 起)

在由 p 指示的未初始化記憶體位置,透過 uses-allocator 構造 建立給定型別 T 的物件。

等價於

return std::apply(
    [&]<class... Xs>(Xs&&...xs)
    {
        return std::construct_at(p, std::forward<Xs>(xs)...);
    },
    std::uses_allocator_construction_args<T>(alloc, std::forward<Args>(args)...));

目錄

[編輯] 引數

p - 物件將要放置的記憶體位置
alloc - 要使用的分配器
args - 傳遞給 T 建構函式的引數

[編輯] 返回值

指向新建立的型別 T 物件的指標。

[編輯] 異常

可能丟擲 T 的建構函式丟擲的任何異常,通常包括 std::bad_alloc

[編輯] 示例

[編輯] 參閱

檢查指定型別是否支援 uses-allocator 構造
(類模板) [編輯]
透過 uses-allocator 構造建立給定型別的物件
(函式模板) [編輯]