Namespaces
Variants

std::indirect<T, Allocator>:: indirect

From cppreference.net
Memory management library
( exposition only* )
Allocators
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Memory resources
Uninitialized storage (until C++20)
( until C++20* )
( until C++20* )
( until C++20* )

Garbage collector support (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(注:このHTML要素には翻訳対象のテキストコンテンツが含まれていないため、元の構造を保持したまま出力します)
constexpr explicit indirect ( ) ;
(1) (C++26以降)
constexpr explicit indirect ( std:: allocator_arg_t , const Allocator & a ) ;
(2) (C++26以降)
template < class U = T >
constexpr explicit indirect ( U && v ) ;
(3) (C++26以降)
template < class U = T >

constexpr explicit indirect ( std:: allocator_arg_t , const Allocator & a,

U && v ) ;
(4) (C++26以降)
template < class ... Args >
constexpr explicit indirect ( std:: in_place_t , Args && ... args ) ;
(5) (C++26以降)
template < class ... Args >

constexpr explicit indirect ( std:: allocator_arg_t , const Allocator & a,

std:: in_place_t , Args && ... args ) ;
(6) (C++26以降)
template < class I, class ... Args >

constexpr explicit indirect ( std:: in_place_t , std:: initializer_list < I > ilist,

Args && ... args ) ;
(7) (C++26以降)
template < class I, class ... Args >

constexpr explicit indirect ( std:: allocator_arg_t , const Allocator & a,
std:: in_place_t , std:: initializer_list < I > ilist,

Args && ... args ) ;
(8) (C++26以降)
constexpr indirect ( const indirect & other ) ;
(9) (C++26以降)
constexpr indirect ( std:: allocator_arg_t , const Allocator & a,
const indirect & other ) ;
(10) (C++26以降)
constexpr indirect ( indirect && other ) noexcept ;
(11) (C++26以降)
constexpr indirect ( std:: allocator_arg_t , const Allocator & a,
indirect && other ) noexcept ( /* see below */ ) ;
(12) (C++26以降)

新しい indirect オブジェクトを構築します。

目次

パラメータ

a - 関連付けるアロケータ
v - 所有する値を初期化するための値
args - 所有する値を初期化するための引数
il - 所有する値を初期化するための初期化子リスト
other - 所有する値(存在する場合)がコピーされる別の indirect オブジェクト

効果

新しい indirect オブジェクトの構築は以下の手順で構成されます:

1) 関連付けられたアロケータ alloc を構築する :
2) 所有オブジェクトを構築します:
  • オーバーロード ( 1-8 ) の場合、 p std:: allocator_traits < Allocator > :: allocate の呼び出し結果で初期化し、その後 std:: allocator_traits < Allocator > :: construct ( alloc  , p  , args... ) を呼び出します。ここで args... は初期化引数を含む式パックです。
  • オーバーロード ( 9-12 ) の場合:
    • other が無効値の場合、所有オブジェクトは構築されず、構築後の * this も無効値となります。
    • それ以外の場合、 other が右辺値参照であり、かつ alloc other. alloc と等しい場合、 * this other の所有オブジェクトの所有権を取得します。
    • それ以外の場合、所有オブジェクトは上記のように alloc を使用して構築されます。
オーバーロード 初期化子... valueless_after_move()
構築後
alloc 所有オブジェクト
( 1 ) (空) (空) false
( 2 ) a
( 3 ) (空) std:: forward < U > ( v )
( 4 ) a
( 5 ) (空) std:: forward < Args > ( args )
( 6 ) a
( 7 ) (空) ilist, std:: forward < Args > ( args )
( 8 ) a
( 9 ) 以下を参照 * other
( other が値を所有している場合のみ)
true ( other がvaluelessの場合のみ)
( 10 ) a
( 11 ) std :: move ( other. alloc  ) 所有権を取得
( other が値を所有している場合のみ)
( 12 ) a 以下を参照
9) alloc std:: allocator_traits < Allocator > ::
select_on_container_copy_construction ( other. alloc  )
で直接非リスト初期化されます。
12) 所有オブジェクトは以下のように構築されます:
  • other が値を持たない場合、 * this も値を持ちません。
  • それ以外の場合、 alloc == other. alloc true の場合、 * this other の所有オブジェクトの所有権を取得します。
  • それ以外の場合、 alloc を使用して * std :: move ( other ) で所有オブジェクトを構築します。

制約事項と補足情報

1,2) std:: is_default_constructible_v < T > false の場合、プログラムは不適格となる。

1) このオーバーロードは、 std:: is_default_constructible_v < Allocator > true である場合にのみ、オーバーロード解決に参加します。

3-8) これらのオーバーロードは、 std:: is_constructible_v < T, /* argument types */ > true の場合にのみ、オーバーロード解決に参加します。ここで /* argument types */ は以下を指します:
3,4) U
5,6) Args...
7,8) std:: initializer_list < I > & , Args...

3,5,7) これらのオーバーロードは、 std:: is_default_constructible_v < Allocator > true の場合にのみ、オーバーロード解決に参加します。
3,4) これらのオーバーロードは、以下の値がすべて false である場合にのみオーバーロード解決に参加します:

9,10) std:: is_copy_constructible_v < T > false の場合、プログラムは不適格です。
11,12) 構築が完了すると、 other は無効値となります。
12) std:: allocator_traits < Allocator > :: is_always_equal :: value false であり、かつ T 不完全型 である場合、プログラムは不適格となる。

例外

std:: allocator_traits < Allocator > :: allocate または std:: allocator_traits < Allocator > :: construct が例外を送出しない限り、何も送出しません。

12)
noexcept 指定:
noexcept ( std:: allocator_traits < Allocator > :: is_always_equal :: value )

関連項目

アロケータ対応コンストラクタのオーバーロードを選択するために使用されるタグ型
(クラス)
インプレース構築タグ
(タグ)