std::flat_map<Key,T,Compare,KeyContainer,MappedContainer>:: flat_map
|
flat_map
(
)
: flat_map ( key_compare ( ) ) { } |
(1) | (C++23以降) |
|
template
<
class
Allocator
>
flat_map ( const flat_map & , const Allocator & alloc ) ; |
(2) | (C++23以降) |
|
template
<
class
Allocator
>
flat_map ( flat_map && , const Allocator & alloc ) ; |
(3) | (C++23以降) |
|
flat_map
(
key_container_type key_cont, mapped_container_type mapped_cont,
const key_compare & comp = key_compare ( ) ) ; |
(4) | (C++23以降) |
|
template
<
class
Allocator
>
flat_map
(
const
key_container_type
&
key_cont,
|
(5) | (C++23以降) |
|
template
<
class
Allocator
>
flat_map
(
const
key_container_type
&
key_cont,
|
(6) | (C++23以降) |
|
flat_map
(
std::
sorted_unique_t
, key_container_type key_cont,
mapped_container_type mapped_cont,
|
(7) | (C++23以降) |
|
template
<
class
Allocator
>
flat_map
(
std::
sorted_unique_t
,
const
key_container_type
&
key_cont,
|
(8) | (C++23以降) |
|
template
<
class
Allocator
>
flat_map
(
std::
sorted_unique_t
,
const
key_container_type
&
key_cont,
|
(9) | (C++23以降) |
|
explicit
flat_map
(
const
key_compare
&
comp
)
: c ( ) , compare ( comp ) { } |
(10) | (C++23以降) |
|
template
<
class
Allocator
>
flat_map ( const key_compare & comp, const Allocator & alloc ) ; |
(11) | (C++23以降) |
|
template
<
class
Allocator
>
explicit flat_map ( const Allocator & alloc ) ; |
(12) | (C++23以降) |
|
template
<
class
InputIter
>
flat_map
(
InputIter first, InputIter last,
|
(13) | (C++23以降) |
|
template
<
class
InputIter,
class
Allocator
>
flat_map
(
InputIter first, InputIter last,
|
(14) | (C++23以降) |
|
template
<
class
InputIter,
class
Allocator
>
flat_map ( InputIter first, InputIter last, const Allocator & alloc ) ; |
(15) | (C++23以降) |
|
template
<
container-compatible-range
<
value_type
>
R
>
flat_map
(
std::
from_range_t
, R
&&
rg,
const
key_compare
&
comp
)
|
(16) | (C++23以降) |
|
template
<
container-compatible-range
<
value_type
>
R
>
flat_map
(
std::
from_range_t
fr, R
&&
rg
)
|
(17) | (C++23以降) |
|
template
<
container-compatible-range
<
value_type
>
R,
class
Allocator
>
flat_map ( std:: from_range_t , R && rg, const Allocator & alloc ) ; |
(18) | (C++23以降) |
|
template
<
container-compatible-range
<
value_type
>
R,
class
Allocator
>
flat_map
(
std::
from_range_t
, R
&&
rg,
const
key_compare
&
comp,
|
(19) | (C++23以降) |
|
template
<
class
InputIter
>
flat_map
(
std::
sorted_unique_t
s, InputIter first, InputIter last,
|
(20) | (C++23以降) |
|
template
<
class
InputIter,
class
Allocator
>
flat_map
(
std::
sorted_unique_t
s, InputIter first, InputIter last,
|
(21) | (C++23以降) |
|
template
<
class
InputIter,
class
Allocator
>
flat_map
(
std::
sorted_unique_t
s, InputIter first, InputIter last,
|
(22) | (C++23以降) |
|
flat_map
(
std::
initializer_list
<
value_type
>
init,
const
key_compare
&
comp
=
key_compare
(
)
)
|
(23) | (C++23以降) |
|
template
<
class
Allocator
>
flat_map
(
std::
initializer_list
<
value_type
>
init,
const
key_compare
&
comp,
|
(24) | (C++23以降) |
|
template
<
class
Allocator
>
flat_map ( std:: initializer_list < value_type > init, const Allocator & alloc ) ; |
(25) | (C++23以降) |
|
flat_map
(
std::
sorted_unique_t
s,
std::
initializer_list
<
value_type
>
init,
const
key_compare
&
comp
=
key_compare
(
)
)
|
(26) | (C++23以降) |
|
template
<
class
Allocator
>
flat_map
(
std::
sorted_unique_t
s,
std::
initializer_list
<
value_type
>
init,
|
(27) | (C++23以降) |
|
template
<
class
Allocator
>
flat_map
(
std::
sorted_unique_t
s,
std::
initializer_list
<
value_type
>
init,
|
(28) | (C++23以降) |
様々なデータソースから新しいコンテナアダプタを構築し、オプションでユーザー提供の比較関数オブジェクト comp および/またはアロケータ alloc を使用します。
c
を
other.
c
の内容のコピーで構築し、
compare
を
other.
compare
で構築する。
以下の
allocator usage note
を参照。
c.keys
を
std
::
move
(
key_cont
)
で初期化し、
c.values
を
std
::
move
(
mapped_cont
)
で初期化し、
compare
を
comp
で初期化します。その後、基となる範囲
[
begin
(
)
,
end
(
)
)
を
value_comp()
に関してソートします。最後に、以下のように重複要素を削除します:
auto zv = views:: zip ( c. keys , c. values ) ;
auto it = ranges:: unique ( zv, key_equiv ( compare ) ) . begin ( ) ;
auto dist = distance ( zv. begin ( ) , it ) ;
c. keys . erase ( c. keys . begin ( ) + dist, c. keys . end ( ) ) ;
c. values . erase ( c. values . begin ( ) + dist, c. values . end ( ) ) ; 。
c.keys
を
std
::
move
(
key_cont
)
で初期化し、
c.values
を
std
::
move
(
mapped_cont
)
で初期化し、
compare
を
comp
で初期化する。
[
first
,
last
)
の内容で構築します。これは
insert
(
first, last
)
;
と等価です。
c
を
rg
の内容で初期化します。これは
insert_range
(
std::
forward
<
R
>
(
rg
)
)
;
によって行われるかのように行われます。
[
first
,
last
)
の内容で基盤となるコンテナを構築します。これは
insert
(
first, last
)
によって行われるかのように動作します。
オーバーロードに関する注記
(13-15,20-22)
:
[
first
,
last
)
が
有効な範囲
でない場合、動作は未定義です。
Note for overloads (4-6,13-19,23-25) : If multiple elements in the range have keys that compare equivalent, it is unspecified which element is inserted (pending LWG2844 (注:このテキストはHTMLタグ内の表示テキストであり、LWG2844はC++標準ライブラリのIssue番号であるため、翻訳対象外としました) ).
目次 |
アロケータ使用上の注意
コンストラクタ
(2,3,5,6,8,9,11,12,14,15,17,19,21,22,24,25,27,28)
は、対応する非アロケータコンストラクタと同等ですが、基盤となるコンテナ
c.keys
および
c.values
が
uses-allocator construction
で構築される点が異なります。
これらのオーバーロードは、
std::
uses_allocator_v
<
container_type, Allocator
>
が
true
の場合にのみ、オーバーロード解決に参加します。
パラメータ
| key_cont | - | 基盤となるキーコンテナを初期化するためのソースとして使用するコンテナ |
| mapped_cont | - | 基盤となる値コンテナを初期化するためのソースとして使用するコンテナ |
| other | - |
基盤となるコンテナの要素を初期化するためのソースとして使用する別の
flat_map
|
| alloc | - | 基盤となるコンテナのすべてのメモリ割り当てに使用するアロケータ |
| comp | - | キーのすべての比較に使用する関数オブジェクト |
| first, last | - | コピーする要素のソース 範囲 を定義するイテレータのペア |
| init | - | 基盤となるコンテナの要素を初期化するための初期化子リスト |
| rg | - |
基盤となるコンテナを初期化するためのソースとして使用する
コンテナ互換範囲
(つまり、要素が
value_type
に変換可能な
input_range
)
|
| fr | - | 含まれるメンバが範囲構築されるべきであることを示す 曖昧性解消タグ |
| s | - | 入力シーケンスが value_comp() に関してソートされており、すべての要素が一意であることを示す 曖昧性解消タグ |
| 型要件 | ||
-
InputIt
は
LegacyInputIterator
の要件を満たさなければならない。
|
||
-
Compare
は
Compare
の要件を満たさなければならない。
|
||
-
Allocator
は
Allocator
の要件を満たさなければならない。
|
||
計算量
[
first
,
last
)
が
value_comp()
に関してソートされている場合は
N
に対して線形、それ以外の場合は
𝓞(N·log(N))
。ここで
N
はこの呼び出し前の
key_cont.
size
(
)
の値。
[
first
,
last
)
のサイズに対して線形。
例外
Allocator::allocate
の呼び出しは例外をスローする可能性があります。
注記
コンテナのムーブ構築後(オーバーロード ( 3 ) )、 other への参照、ポインタ、およびイテレータ(終端イテレータを除く)は有効なままですが、現在は * this 内の要素を参照します。現在の標準では、 [container.reqmts]/67 の包括的な記述によってこの保証がなされており、 LWG issue 2321 を通じてより直接的な保証が検討されています。
例
|
このセクションは不完全です
理由: 例がありません |
関連項目
|
コンテナアダプタに値を代入する
(公開メンバ関数) |