Namespaces
Variants

std::experimental::pmr::polymorphic_allocator<T>:: construct

From cppreference.net
template < class U, class ... Args >
void construct ( U * p, Args && ... args ) ;
(1) (ライブラリ基盤 TS)
template < class T1, class T2, class ... Args1 , class ... Args2 >

void construct ( std:: pair < T1, T2 > * p,
std:: piecewise_construct_t ,
std:: tuple < Args1... > x,

std:: tuple < Args2... > y ) ;
(2) (ライブラリ基盤 TS)
template < class T1, class T2 >
void construct ( std:: pair < T1, T2 > * p ) ;
(3) (ライブラリ基盤 TS)
template < class T1, class T2, class U, class V >
void construct ( std:: pair < T1, T2 > * p, U && x, V && y ) ;
(4) (ライブラリ基盤 TS)
template < class T1, class T2, class U, class V >
void construct ( std:: pair < T1, T2 > * p, const std:: pair < U, V > & xy ) ;
(5) (ライブラリ基盤 TS)
template < class T1, class T2, class U, class V >
void construct ( std:: pair < T1, T2 > * p, std:: pair < U, V > && xy ) ;
(6) (ライブラリ基盤 TS)

割り当て済みだが初期化されていないストレージ( p が指す)内にオブジェクトを構築し、指定されたコンストラクタ引数を渡します。オブジェクト自体がアロケータを使用する型である場合、またはstd::pairである場合は、 this->resource() を構築されたオブジェクトに伝達します。

1) もし std:: uses_allocator < U, memory_resource * > :: value == false (型 U がアロケータを使用しない) かつ std:: is_constructible < U, Args... > :: value == true の場合、オブジェクトを以下のように構築する :: new ( ( void * ) p ) U ( std:: forward < Args > ( args ) ... ) ;

そうでなければ、 std:: uses_allocator < U, memory_resource * > :: value == true (型 U がアロケータを使用する場合、例えばコンテナである場合)かつ std:: is_constructible < U, std:: allocator_arg_t , memory_resource * , Args... > :: value == true の場合、以下のようにオブジェクトを構築する: :: new ( ( void * ) p ) U ( std:: allocator_arg , this - > resource ( ) , std:: forward < Args > ( args ) ... ) ;

そうでなければ、 std:: uses_allocator < U, memory_resource * > :: value == true (型 U がアロケータを使用する場合、例えばコンテナである場合)かつ std:: is_constructible < U, Args..., memory_resource * > :: value == true の場合、オブジェクトを以下のように構築する: :: new ( ( void * ) p ) U ( std:: forward < Args > ( args ) ..., this - > resource ( ) ) ;

それ以外の場合、プログラムは不適格です。

2) まず、 T1 または T2 のいずれかがアロケータ対応である場合、以下の3つのルールに従って、 x および y を変更し、 this->resource() を含む2つの新しいタプル xprime および yprime を生成します:

2a) もし T1 がアロケータ対応でなく ( std:: uses_allocator < T1, memory_resource * > :: value == false ) かつ std:: is_constructible < T1, Args1... > :: value == true ならば、 xprime は変更されていない x である。

2b) もし T1 がアロケータ対応 ( std:: uses_allocator < T1, memory_resource * > :: value == true ) であり、かつそのコンストラクタがアロケータタグを受け取る場合 ( std:: is_constructible < T1, std:: allocator_arg_t , memory_resource * , Args1... > :: value == true )、その場合 xprime std:: tuple_cat ( std:: make_tuple ( std:: allocator_arg , this - > resource ( ) ) , std :: move ( x ) ) となります。

2c) もし T1 がアロケータ対応 ( std:: uses_allocator < T1, memory_resource * > :: value == true ) であり、かつそのコンストラクタが最後の引数としてアロケータを受け取る場合 ( std:: is_constructible < T1, Args1..., memory_resource * > :: value == true )、その場合 xprime std:: tuple_cat ( std :: move ( x ) , std:: make_tuple ( this - > resource ( ) ) ) となります。

2d) それ以外の場合、プログラムは不適格です。

同じ規則が T2 y yprime への置換に適用されます。

xprime yprime が構築された後、割り当てられたストレージ内に p のペアを、以下のように構築します :: new ( ( void * ) p ) pair < T1, T2 > ( std:: piecewise_construct , std :: move ( xprime ) , std :: move ( yprime ) ) ;

3) 次と同等: construct ( p, std:: piecewise_construct , std:: tuple <> ( ) , std:: tuple <> ( ) ) 。つまり、メモリリソースをペアのメンバ型がそれを受け入れる場合に渡す。

4) 次と同等

construct ( p, std:: piecewise_construct , std:: forward_as_tuple ( std:: forward < U > ( x ) ) ,
std:: forward_as_tuple ( std:: forward < V > ( y ) ) )

5) 次と同等

construct ( p, std:: piecewise_construct , std:: forward_as_tuple ( xy. first ) ,
std:: forward_as_tuple ( xy. second ) )

6) 次と同等

construct ( p, std:: piecewise_construct , std:: forward_as_tuple ( std:: forward < U > ( xy. first ) ) ,
std:: forward_as_tuple ( std:: forward < V > ( xy. second ) ) )

目次

翻訳の説明: - 「Contents」を「目次」に翻訳しました - HTMLタグ、属性、リンク先は一切変更していません - C++関連の用語(Parameters、Return value、Notes、See also)は原文のまま保持しています - 番号付けや構造は完全に維持しています - フォーマットは元のHTML構造をそのまま保持しています

パラメータ

p - 確保済みだが初期化されていないストレージへのポインタ
args... - T のコンストラクタに渡すコンストラクタ引数
x - T1 のコンストラクタに渡すコンストラクタ引数
y - T2 のコンストラクタに渡すコンストラクタ引数
xy - 2つのメンバーがそれぞれ T1 T2 のコンストラクタ引数となるペア

戻り値

(なし)

注記

この関数は( std::allocator_traits を通じて)アロケータ対応オブジェクト(例: std::vector )によって呼び出されます。これらのオブジェクトは、使用するアロケータとして std::polymorphic_allocator が指定されたものです。 memory_resource* は暗黙的に polymorphic_allocator に変換されるため、メモリリソースポインタはポリモーフィックアロケータを使用するアロケータ対応サブオブジェクトに伝播します。

関連項目

[static]
割り当てられたストレージ内でオブジェクトを構築する
(関数テンプレート)
(C++20まで)
割り当てられたストレージ内でオブジェクトを構築する
( std::allocator<T> の公開メンバ関数)