名前空間
変種
操作

std::flat_multimap<Key,T,Compare,KeyContainer,MappedContainer>::operator=

From cppreference.com
 
 
 
 
flat_multimap& operator=( const flat_multimap& other );
(1) (C++23から)
(暗黙的に宣言)
flat_multimap& operator=( flat_multimap&& other );
(2) (C++23から)
(暗黙的に宣言)
flat_multimap& operator=( std::initializer_list<value_type> ilist );
(3) (C++23から)

コンテナアダプタの内容を指定された引数の内容で置き換えます。

1) コピー代入演算子。contentsを`other`のcontentsのコピーで置き換えます。実質的には `c = other.c; comp = other.comp;` を呼び出します。
2) ムーブ代入演算子。ムーブセマンティクスを使用して、contentsを`other`のものと置き換えます。実質的には `c = std::move(other.c); comp = std::move(other.comp);` を呼び出します。
3) コンテナの内容を初期化リスト ilist で指定された内容で置き換えます。

目次

[編集] パラメータ

その他 - ソースとして使用される別のコンテナアダプタ
ilist - ソースとして使用される初期化リスト

[編集] 戻り値

*this

[編集] 計算量

1,2) 基底となるコンテナの operator= の計算量に相当します。
3) *this および ilist のサイズに対する線形。

[編集]

#include <flat_map>
#include <initializer_list>
#include <print>
#include <utility>
 
int main()
{
    std::flat_multimap<int, int> x{{1, 1}, {2, 2}, {3, 3}}, y, z;
    const auto w = {std::pair<const int, int>{4, 4}, {5, 5}, {6, 6}, {7, 7}};
 
    std::println("Initially:");
    std::println("x = {}", x);
    std::println("y = {}", y);
    std::println("z = {}", z);
 
    y = x; // overload (1)
    std::println("Copy assignment copies data from x to y:");
    std::println("x = {}", x);
    std::println("y = {}", y);
 
    z = std::move(x); // overload (2)
    std::println("Move assignment moves data from x to z, modifying both x and z:");
    std::println("x = {}", x);
    std::println("z = {}", z);
 
    z = w; // overload (3)
    std::println("Assignment of initializer_list w to z:");
    std::println("w = {}", w);
    std::println("z = {}", z);
}

出力

Initially:
x = {1: 1, 2: 2, 3: 3}
y = {}
z = {}
Copy assignment copies data from x to y:
x = {1: 1, 2: 2, 3: 3}
y = {1: 1, 2: 2, 3: 3}
Move assignment moves data from x to z, modifying both x and z:
x = {}
z = {1: 1, 2: 2, 3: 3}
Assignment of initializer_list w to z:
w = {4: 4, 5: 5, 6: 6, 7: 7}
z = {4: 4, 5: 5, 6: 6, 7: 7}

[編集] 関連項目

flat_multimapを構築します
(公開メンバ関数) [編集]
基底コンテナを置き換える
(public member function) [編集]
English 日本語 中文(简体) 中文(繁體)