std::flat_set<Key,Compare,KeyContainer>:: operator=
From cppreference.net
|
flat_set
&
operator
=
(
const
flat_set
&
other
)
;
|
(1) |
(C++23以降)
(暗黙的に宣言) |
|
flat_set
&
operator
=
(
flat_set
&&
other
)
;
|
(2) |
(C++23以降)
(暗黙的に宣言) |
|
flat_set
&
operator
=
(
std::
initializer_list
<
key_type
>
ilist
)
;
|
(3) | (C++23以降) |
コンテナアダプタの内容を指定された引数の内容で置き換えます。
1)
コピー代入演算子。内容を
other
の内容のコピーで置き換えます。実質的に
c
=
other.
c
;
comp
=
other.
comp
;
を呼び出します。
2)
ムーブ代入演算子。内容を
other
の内容で置き換える(ムーブセマンティクスを使用)。実質的に
c
=
std
::
move
(
other.
c
)
;
comp
=
std
::
move
(
other.
comp
)
;
を呼び出す。
3)
内容を初期化子リスト
ilist
で指定されたものに置き換えます。
目次 |
パラメータ
| other | - | ソースとして使用する別のコンテナアダプタ |
| ilist | - | ソースとして使用する初期化子リスト |
戻り値
* this
計算量
1,2)
基となるコンテナの
operator
=
と同等です。
3)
*
this
および
ilist
のサイズに対して線形。
例
このコードを実行
#include <flat_set> #include <initializer_list> #include <print> int main() { std::flat_set<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_set
を構築する
(公開メンバ関数) |
|
|
基盤となるコンテナを置き換える
(公開メンバ関数) |