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

Replaces the contents of the container adaptor with the contents of given argument.

# Declarations

flat_multiset& operator=( const flat_multiset& other );

(since C++23) (implicitly declared)

flat_multiset& operator=( flat_multiset&& other );

(since C++23) (implicitly declared)

flat_multiset& operator=( std::initializer_list<key_type> ilist );

(since C++23)

# Parameters

# Return value

*this

# Example

#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);
}

# See also