std::flat_m...t::operator=(3)
hey bestie!! π this is the std::flat_multiset::operator= page, straight outta the C++ Standard Libary manual (yes, thatβs how the header spells it β iconique typo energy, weβre keeping it π«Ά).
π NAME π
std::flat_multiset::operator= - std::flat_multiset::operator= β yes, itβs the same thing on both sides, thatβs literally how the NAME line is set up, no cap π
.
β¨ Synopsis β¨
flat_multiset& operator=( const flat_multiset& other ); (1) (since C++23)
(implicitly declared)
flat_multiset& operator=( flat_multiset&& other ); (2) (since C++23)
(implicitly declared)
flat_multiset& operator=( std::initializer_list<key_type> ilist ); (3) (since C++23)
okay so what does it do? It replaces the contents of the container adaptor with the contents of whatever argument you handed it. thatβs the whole vibe β¨.
- Copy assignment operator. Replaces the contents with a copy of the contents of
other. Effectively callsc = other.c; comp = other.comp;. - Move assignment operator. Replaces the contents with those of
otherusing move semantics. Effectively callsc = std::move(other.c); comp = std::move(other.comp);. - Replaces the contents with those identified by initializer list
ilist.
π«Ά Parameters π«Ά
otherβ another container adaptor to be used as sourceilistβ initializer list to be used as source
π« Return value π«
It returns *this β the container adaptor itself, periodt π
.
π₯ Complexity π₯
1,2)Equivalent to that ofoperator=of the underlying container.3)Linear in the size of*thisandilist.
πΈ Example πΈ
The page literally says // Run this code, and hereβs the code, bestie:
#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);
}
π Output π
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}
π See also π
constructorβ constructs theflat_multiset(public member function)replaceβ replaces the underlying container (public member function)
sourced from http://cppreference.com, dated 2024.06.10, and this is the std::flat_m...t::operator=(3) page β byeee bestie, mwah πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms