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.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());.
[first, last) の内容で構築します。 insert(first, last); と同等です。c を rg の内容で、insert_range(std::forward<R>(rg)); のように初期化します。[first, last) の内容で、insert(first, last) のように初期化します。オーバーロード (13-15,20-22) に関する注記: [first, last) が 有効な範囲でない場合、動作は未定義です。
オーバーロード (4-6,13-19,23-25) に関する注意: 範囲内にキーが同等と評価される要素が複数ある場合、どの要素が挿入されるかは未指定です ( LWG2844 参照)。
目次 |
[編集] アロケータ使用上の注意
コンストラクタ (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 | - | 基になる値コンテナを初期化するためのソースとして使用されるコンテナ |
| その他 | - | 基になるコンテナの要素を初期化するためのソースとして使用される別の `flat_map` |
| alloc | - | 基になるコンテナのすべてのメモリ割り当てに使用されるアロケータ |
| comp | - | キーのすべての比較に使用される関数オブジェクト。 |
| first, last | - | コピーする要素のソース 範囲 を定義するイテレータペア |
| init | - | 基になるコンテナの要素を初期化するための初期化子リスト |
| rg | - | コンテナ互換範囲 (すなわち、input_range であり、その要素が value_type に変換可能) で、基になるコンテナを初期化するためのソースとして使用されます。 |
| fr | - | 保持されているメンバーが範囲構築されることを示す、曖昧さ解消タグ。 |
| s | - | 曖昧さ解消タグ。入力シーケンスが value_comp() に関してソートされており、すべての要素が一意であることを示します。 |
| 型要件 | ||
-InputIt は LegacyInputIterator の要件を満たす必要があります。 | ||
-CompareはCompareの要件を満たす必要がある。 | ||
-Allocator は Allocator の要件を満たす必要があります。 | ||
[編集] 計算量
[first, last) が value_comp() に関してソートされている場合は線形、それ以外の場合は 𝓞(N·log(N))。ここで N は、この呼び出し前の key_cont.size() の値です。[first, last) のサイズに対する線形。[編集] 例外
Allocator::allocate の呼び出しが例外をスローする可能性があります。
[編集] 注意
コンテナの移動構築 (オーバーロード (3)) 後、`other` への参照、ポインタ、イテレータ (末尾イテレータを除く) は有効なままですが、現在 `*this` にある要素を参照します。現在の標準では、[container.reqmts]/67 の包括的な声明を通じてこの保証が提供され、より直接的な保証が LWG issue 2321 経由で検討されています。
[編集] 例
| このセクションは未完成です 理由: 例がありません |
[編集] 関連項目
| コンテナアダプタに値を割り当てる (公開メンバ関数) |