Namespaces
Variants

std::unordered_multimap<Key,T,Hash,KeyEqual,Allocator>:: unordered_multimap

From ja.cppreference.net

(1)
unordered_multimap ( )
: unordered_multimap ( size_type ( /* unspecified */ ) ) { }
(C++11以降)
(C++20まで)
unordered_multimap ( ) ;
(C++20以降)
explicit unordered_multimap ( size_type bucket_count,

const Hash & hash = Hash ( ) ,
const key_equal & equal = key_equal ( ) ,

const Allocator & alloc = Allocator ( ) ) ;
(2) (C++11以降)
unordered_multimap ( size_type bucket_count,

const Allocator & alloc )

: unordered_multimap ( bucket_count, Hash ( ) , key_equal ( ) , alloc ) { }
(3) (C++14以降)
unordered_multimap ( size_type bucket_count,

const Hash & hash,
const Allocator & alloc )

: unordered_multimap ( bucket_count, hash, key_equal ( ) , alloc ) { }
(4) (C++14以降)
explicit unordered_multimap ( const Allocator & alloc ) ;
(5) (C++11以降)
template < class InputIt >

unordered_multimap ( InputIt first, InputIt last,
size_type bucket_count = /* 未指定 */ ,
const Hash & hash = Hash ( ) ,
const key_equal & equal = key_equal ( ) ,

const Allocator & alloc = Allocator ( ) ) ;
(6) (C++11以降)
template < class InputIt >

unordered_multimap ( InputIt first, InputIt last,
size_type bucket_count,
const Allocator & alloc )
: unordered_multimap ( first, last,

bucket_count, Hash ( ) , key_equal ( ) , alloc ) { }
(7) (C++14以降)
template < class InputIt >

unordered_multimap ( InputIt first, InputIt last,
size_type bucket_count,
const Hash & hash,
const Allocator & alloc )
: unordered_multimap ( first, last,

bucket_count, hash, key_equal ( ) , alloc ) { }
(8) (C++14以降)
unordered_multimap ( const unordered_multimap & other ) ;
(9) (C++11以降)
unordered_multimap ( const unordered_multimap & other, const Allocator & alloc ) ;
(10) (C++11以降)
unordered_multimap ( unordered_multimap && other ) ;
(11) (C++11以降)
unordered_multimap ( unordered_multimap && other, const Allocator & alloc ) ;
(12) (C++11以降)
unordered_multimap ( std:: initializer_list < value_type > init,

size_type bucket_count = /* 未指定 */ ,
const Hash & hash = Hash ( ) ,
const key_equal & equal = key_equal ( ) ,

const Allocator & alloc = Allocator ( ) ) ;
(13) (C++11以降)
unordered_multimap ( std:: initializer_list < value_type > init,

size_type bucket_count,
const Allocator & alloc )
: unordered_multimap ( init, bucket_count,

Hash ( ) , key_equal ( ) , alloc ) { }
(14) (C++14以降)
unordered_multimap ( std:: initializer_list < value_type > init,

size_type bucket_count,
const Hash & hash,
const Allocator & alloc )
: unordered_multimap ( init, bucket_count,

hash, key_equal ( ) , alloc ) { }
(15) (C++14以降)
template < container-compatible-range < value_type > R >

unordered_multimap ( std:: from_range_t , R && rg,
size_type bucket_count = /* 説明を参照 */ ,
const Hash & hash = Hash ( ) ,
const key_equal & equal = key_equal ( ) ,

const Allocator & alloc = Allocator ( ) ) ;
(16) (C++23以降)
template < container-compatible-range < value_type > R >

unordered_multimap ( std:: from_range_t , R && rg,
size_type bucket_count,
const Allocator & alloc )
: unordered_multimap ( std:: from_range , std:: forward < R > ( rg ) ,

bucket_count, Hash ( ) , key_equal ( ) , alloc ) { }
(17) (C++23以降)
template < container-compatible-range < value_type > R >

unordered_multimap ( std:: from_range_t , R && rg,
size_type bucket_count,
const Hash & hash,
const Alloc & alloc )
: unordered_multimap ( std:: from_range , std:: forward < R > ( rg ) ,

bucket_count, hash, key_equal ( ) , alloc ) { }
(18) (C++23以降)

様々なデータソースから新しいコンテナを構築します。オプションでユーザー指定の bucket_count を最小バケット数として使用し、 hash をハッシュ関数、 equal をキー比較関数、 alloc をアロケータとして使用します。

1-5) 空のコンテナを構築します。 max_load_factor() を 1.0 に設定します。デフォルトコンストラクタの場合、バケット数は未指定です。
6-8) 範囲 [ first , last ) の内容でコンテナを構築します。 max_load_factor() を 1.0 に設定します。
9,10) コピーコンストラクタ。コンテナを other の内容のコピーで構築し、負荷係数、述語、およびハッシュ関数もコピーします。 alloc が提供されない場合、アロケータは std:: allocator_traits < allocator_type > :: select_on_container_copy_construction ( other. get_allocator ( ) ) を呼び出すことで取得されます。

テンプレートパラメータ Allocator は、 クラステンプレート引数推論 で使用される場合、最初の引数からのみ推論されます。

(C++23以降)
11,12) ムーブコンストラクタ . other の内容をムーブセマンティクスを使用してコンテナを構築します。 alloc が提供されない場合、アロケータは other に属するアロケータからのムーブ構築によって取得されます。

テンプレートパラメータ Allocator は、 クラステンプレート引数推論 で使用される際、最初の引数からのみ推論されます。

(C++23以降)
13-15) 初期化子リストコンストラクタ . 初期化子リスト init の内容でコンテナを構築する。 unordered_multimap ( init. begin ( ) , init. end ( ) ) と同じ。
16-18) コンテナを rg の内容で構築します。

目次

パラメータ

alloc - このコンテナのすべてのメモリ割り当てに使用するアロケータ
bucket_count - 初期化時に使用する最小バケット数。指定されない場合、未規定のデフォルト値が使用される
hash - 使用するハッシュ関数
equal - このコンテナのすべてのキー比較に使用する比較関数
first, last - コピーする要素のソース範囲を定義するイテレータのペア range
rg - container compatible range 、すなわち、要素が value_type に変換可能な input_range
other - コンテナの要素を初期化するためのソースとして使用する別のコンテナ
init - コンテナの要素を初期化するための初期化子リスト
型要件
-
InputIt は LegacyInputIterator の要件を満たさなければならない

計算量

1-5) 定数。
6-8) 平均ケース線形(すなわち O(N) 、ここで N は std:: distance ( first, last ) )、最悪ケース二次、すなわち O(N 2 ) 。
9,10) サイズに対して線形 other 。
11,12) 定数。もし alloc が与えられ、かつ alloc ! = other. get_allocator ( ) の場合、線形。
13-15) 平均ケース O(N) ( N は std:: size ( init ) )、最悪ケース O(N 2 ) 。
16-18) 平均ケース O(N) ( N は ranges:: distance ( rg ) )、最悪ケース O(N 2 ) 。

例外

Allocator::allocateへの呼び出しは例外をスローする可能性があります。

注記

コンテナのムーブ構築(オーバーロード (4))の後、元々 other 内の要素を指していた参照、ポインタ、イテレータは有効なままですが、現在は *this 内の要素を指します。現在の標準は、[container.reqmts]/67 の包括的な文によってこの保証を行っており、LWG issue 2321 を介してより直接的な保証が検討されています。

C++23まで正式に要求されていませんが、一部の実装は既にテンプレートパラメータ Allocator を以前のモードで 非推定文脈 に配置しています。

機能テスト マクロ 値 標準 機能
__cpp_lib_containers_ranges 202202L (C++23) レンジ対応 構築と挿入;オーバーロード (16-18)

例

不具合報告

以下の動作変更の欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。

DR 適用対象 公開時の動作 正しい動作
LWG 2193 C++11 デフォルトコンストラクタ ( 1 ) がexplicitであった non-explicitに変更
LWG 2230 C++11 オーバーロード ( 13 ) のセマンティクスが規定されていなかった 規定された

関連項目

コンテナに値を代入する
(公開メンバ関数)