std::multiset<Key,Compare,Allocator>::multiset
提供: cppreference.com
multiset(); explicit multiset( const Compare& comp, {{#pad:|17}} const Allocator& alloc = Allocator() ); |
(1) | |
explicit multiset( const Allocator& alloc ); |
(1) | (C++11以上) |
| (2) | ||
template< class InputIt > multiset( InputIt first, InputIt last, {{#pad:|8}} const Compare& comp = Compare(), {{#pad:|8}} const Allocator& alloc = Allocator() ); |
||
template< class InputIt > multiset( InputIt first, InputIt last, {{#pad:|8}} const Allocator& alloc ); |
(C++14以上) | |
multiset( const multiset& other ); |
(3) | |
multiset( const multiset& other, const Allocator& alloc ); |
(3) | (C++11以上) |
multiset( multiset&& other ); |
(4) | (C++11以上) |
multiset( multiset&& other, const Allocator& alloc ); |
(4) | (C++11以上) |
| (5) | ||
multiset( std::initializer_list<value_type> init, {{#pad:|8}} const Compare& comp = Compare(), {{#pad:|8}} const Allocator& alloc = Allocator() ); |
(C++11以上) | |
multiset( std::initializer_list<value_type> init, {{#pad:|8}} const Allocator& ); |
(C++14以上) | |
オプションでユーザ提供のアロケータ alloc または比較関数 comp を使用して、様々なデータソースから新しいコンテナを構築します。
1) 空のコンテナを構築します。
2) 範囲
[first, last) の内容を持つコンテナを構築します。 3) コピーコンストラクタ。
other の内容のコピーを持つコンテナを構築します。 alloc が指定されない場合、アロケータは std::allocator_traits<allocator_type>::select_on_container_copy_construction(other.get_allocator()) を呼ぶことによって取得されます。4) ムーブコンストラクタ。 ムーブセマンティクスを用いて
other の内容を持つコンテナを構築します。 alloc が指定されない場合、アロケータは other の持つアロケータからムーブ構築によって取得されます。5) 初期化子リスト
init の内容を持つコンテナを構築します。 引数
| alloc | - | このコンテナのすべてのメモリ確保に使用されるアロケータ |
| comp | - | キーのすべての比較に使用される比較関数 |
| first, last | - | 要素をコピーする範囲 |
| other | - | コンテナの要素を初期化するためのソースとして使用される別のコンテナ |
| init | - | コンテナの要素を初期化するための初期化子リスト |
| 型の要件 | ||
-InputIt は LegacyInputIterator の要件を満たさなければなりません。
| ||
-Compare は Compare の要件を満たさなければなりません。
| ||
-Allocator は Allocator の要件を満たさなければなりません。
|
計算量
1) 一定。
2) 一般的には N log(N)、ただし
N = std::distance(first, last)。 指定範囲が value_comp() によってすでにソートされている場合は N に比例。3)
other のサイズに比例。4) 一定。
alloc が指定されていて alloc != other.get_allocator() であれば比例。5) 一般的には N log(N)、ただし
N = init.size())。 指定範囲が value_comp() によってすでにソートされている場合は N に比例。例外
Allocator::allocate の呼び出しは例外を投げるかもしれません。
ノート
コンテナのムーブ構築 (オーバーロード (4)) の後、 other を指す参照、ポインタ、イテレータ (終端イテレータは除く) は有効なまま残りますが、以後 *this 内の要素を指すようになります。 現行の標準ではこの保証は [container.requirements.general]/12 の包括的な文言によってなされていますが、より直接的な保証が LWG 2321 で検討されています。
例
| This section is incomplete Reason: no example |
欠陥報告
以下の動作変更欠陥報告は以前に発行された C++ 標準に遡って適用されました。
| DR | 適用先 | 発行時の動作 | 正しい動作 |
|---|---|---|---|
| LWG 2193 | C++11 | the default constructor is explicit | made non-explicit |
関連項目
| コンテナに値を代入します (パブリックメンバ関数) |