std::multimap<Key,T,Compare,Allocator>:: insert_range
|
template
<
container-compatible-range
<
value_type
>
R
>
void insert_range ( R && rg ) ; |
(C++23以降)
(constexpr C++26以降) |
|
rg の範囲内の各要素のコピーを挿入します。
範囲内の各イテレータは rg 正確に1回デリファレンスされます。
以下のいずれかの条件が満たされる場合、動作は未定義です:
-
value_typeは EmplaceConstructible としてmultimapに * ranges:: begin ( rg ) から構築できません - rg と * this が重複しています
イテレータや参照は無効化されません。
目次 |
パラメータ
| rg | - |
a
container compatible range
, that is, an
input_range
whose elements are convertible to
T
|
計算量
N·log(S+N) 、ここで S は size ( ) 、 N は ranges:: distance ( rg ) です。
注記
| 機能テスト マクロ | 値 | 標準 | 機能 |
|---|---|---|---|
__cpp_lib_containers_ranges
|
202202L
|
(C++23) | Ranges-aware 構築と挿入 |
例
#include <iostream> #include <map> #include <utility> void println(auto, const auto& container) { for (const auto& [key, value] : container) std::cout << '{' << key << ',' << value << '}' << ' '; std::cout << '\n'; } int main() { auto container = std::multimap{std::pair{1, 11}, {3, 33}, {2, 22}, {4, 44}}; const auto rg = {std::pair{-1, -11}, {3, -33}, {-2, -22}}; #ifdef __cpp_lib_containers_ranges container.insert_range(rg); #else container.insert(rg.begin(), rg.end()); #endif println("{}", container); }
出力:
{-2,-22} {-1,-11} {1,11} {2,22} {3,33} {3,-33} {4,44}
関連項目
|
要素を挿入する
またはノード
(C++17以降)
(公開メンバ関数) |