名前空間
変種
操作

std::flat_multiset<Key,Compare,KeyContainer>::operator=

From cppreference.com
 
 
 
 
flat_multiset& operator=( const flat_multiset& other );
(1) (C++23から)
(暗黙的に宣言)
flat_multiset& operator=( flat_multiset&& other );
(2) (C++23から)
(暗黙的に宣言)
flat_multiset& operator=( std::initializer_list<key_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_set>
#include <initializer_list>
#include <print>
 
int main()
{
    std::flat_multiset<int> x{1, 2, 3}, y, z;
    const auto w = {4, 5, 6, 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, 2, 3}
y = {}
z = {}
Copy assignment copies data from x to y:
x = {1, 2, 3}
y = {1, 2, 3}
Move assignment moves data from x to z, modifying both x and z:
x = {}
z = {1, 2, 3}
Assignment of initializer_list w to z:
w = {4, 5, 6, 7}
z = {4, 5, 6, 7}

[編集] 関連項目

flat_multiset を構築します。
(公開メンバ関数) [編集]
基になるコンテナを置き換える
(public member function) [編集]
"https://ja.cppreference.dev/mwiki/index.php?title=cpp/container/flat_multiset/operator%3D&oldid=169510" より取得
English 日本語 中文(简体) 中文(繁體)