std::scoped_allocator_adaptor<OuterAlloc,InnerAlloc...>:: construct
|
定義済みヘッダー
<scoped_allocator>
|
||
|
template
<
class
T,
class
...
Args
>
void construct ( T * p, Args && ... args ) ; |
(1) | |
|
template
<
class
T1,
class
T2,
class
...
Args1
,
class
...
Args2
>
void
construct
(
std::
pair
<
T1, T2
>
*
p,
std::
piecewise_construct_t
,
|
(2) | (C++20まで) |
|
template
<
class
T1,
class
T2
>
void construct ( std:: pair < T1, T2 > * p ) ; |
(3) | (C++20まで) |
|
template
<
class
T1,
class
T2,
class
U,
class
V
>
void construct ( std:: pair < T1, T2 > * p, U && x, V && y ) ; |
(4) | (C++20まで) |
|
template
<
class
T1,
class
T2,
class
U,
class
V
>
void construct ( std:: pair < T1, T2 > * p, const std:: pair < U, V > & xy ) ; |
(5) | (C++20まで) |
|
template
<
class
T1,
class
T2,
class
U,
class
V
>
void construct ( std:: pair < T1, T2 > * p, std:: pair < U, V > && xy ) ; |
(6) | (C++20まで) |
|
ヘルパー関数テンプレート
|
||
|
template
<
class
T,
class
...
Args
>
std:: tuple < /* 下記参照 */ > /*concat-args*/ ( std:: tuple < Args... > && tup ) ; |
(7) |
(
説明専用*
)
(C++20まで) |
割り当て済みだが初期化されていないストレージ( p が指す)内で、外側のアロケータと提供されたコンストラクタ引数を使用してオブジェクトを構築します。オブジェクト自体がアロケータを使用する型である場合 、または std::pair (C++20まで) である場合、内側のアロケータを構築されたオブジェクトに伝達します。
T
by
uses-allocator construction
at the uninitialized memory location indicated by
p
using the outermost allocator.
|
std:: uses_allocator < T, inner_allocator_type > :: value を uses_inner として与える:
このオーバーロードは、
|
(C++20まで) |
|
std::
apply
|
(C++20以降) |
concat-args
<
T1
>
(
std
::
move
(
x
)
)
とし、
yprime
を
concat-args
<
T2
>
(
std
::
move
(
y
)
)
として、
outermost-construct
(
p,
std::
piecewise_construct
, std
::
move
(
xprime
)
, std
::
move
(
yprime
)
)
を呼び出す。
std:: forward_as_tuple ( xarg ) , std:: forward_as_tuple ( yarg ) ) ; 。ただし、 xarg および yarg は以下のように定義される:
| オーバーロード | xarg | yarg |
|---|---|---|
| (4) | std:: forward < U > ( x ) | std:: forward < V > ( y ) |
| (5) | xy. first | xy. second |
| (6) | std:: forward < U > ( xy. first ) | std:: forward < V > ( xy. second ) |
- uses_inner が false かつ std:: is_constructible < T, Args... > :: value が true の場合、 std:: tuple < Args && ... > ( std :: move ( tup ) ) を返す。
-
それ以外の場合、
uses_inner
と
std::
is_constructible
<
T,
std::
allocator_arg_t
,
inner_allocator_type & ,
Args... > :: value の両方が true の場合、 std:: tuple_cat ( std:: tuple < std:: allocator_arg_t , inner_allocator_type & >
( std:: allocator_arg , inner_allocator ( ) ) ,
std:: tuple < Args && ... > ( std :: move ( tup ) ) ) を返す。 -
それ以外の場合、
uses_inner
と
std::
is_constructible
<
T, Args..., inner_allocator_type
&
>
::
value
の両方が
true
の場合、
std::
tuple_cat
(
std::
tuple
<
Args
&&
...
>
(
std
::
move
(
tup
)
)
,
std:: tuple < inner_allocator_type & > ( inner_allocator ( ) ) を返す。 - それ以外の場合、プログラムは不適格となる。
目次 |
パラメータ
| p | - | 確保済みだが初期化されていないストレージへのポインタ |
| args | - |
T
のコンストラクタに渡すコンストラクタ引数
|
| x | - |
T1
のコンストラクタに渡すコンストラクタ引数
|
| y | - |
T2
のコンストラクタに渡すコンストラクタ引数
|
| xy | - |
2つのメンバーがそれぞれ
T1
と
T2
のコンストラクタ引数となるペア
|
| tup | - | マージされる引数 |
注記
この関数は(
std::allocator_traits
を通じて)
std::vector
のようなアロケータ対応オブジェクトによって呼び出されます。これらのオブジェクトはアロケータとして
std::scoped_allocator_adaptor
が指定された場合に使用されます。
inner_allocator_type
自体が
std::scoped_allocator_adaptor
の特殊化であるため、この関数を通じて構築されたアロケータ対応オブジェクトが自身のメンバの構築を開始する際にも、この関数が呼び出されます。
欠陥報告
以下の動作変更の欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。
| DR | 適用対象 | 公開時の動作 | 正しい動作 |
|---|---|---|---|
| LWG 2203 | C++11 |
内部アロケータは値初期化された
inner_allocator_type
オブジェクトから取得されていた
|
inner_allocator()
を呼び出して取得
|
|
LWG 2511
( P0475R1 ) |
C++11 |
concat-args
が
std::tuple
の要素をコピーする可能性があった
|
すべての要素コピー操作を排除 |
| LWG 2586 | C++11 |
inner_allocator_type
右辺値からの構築のみがチェックされていた
|
非const
inner_allocator_type
左辺値からの構築をチェックするように変更
|
| LWG 2975 | C++11 | オーバーロード (1) が制約されていなかった | std::pair を拒否するように制約 |
関連項目
|
[static]
|
割り当てられたストレージ内にオブジェクトを構築する
(関数テンプレート) |
|
(until C++20)
|
割り当てられたストレージ内にオブジェクトを構築する
(
std::allocator<T>
の公開メンバ関数)
|