Namespaces
Variants

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

From cppreference.net

flat_multimap & operator = ( const flat_multimap & other ) ;
(1) (seit C++23)
(implizit deklariert)
flat_multimap & operator = ( flat_multimap && other ) ;
(2) (seit C++23)
(implizit deklariert)
flat_multimap & operator = ( std:: initializer_list < value_type > ilist ) ;
(3) (seit C++23)

Ersetzt den Inhalt des Container-Adapters durch den Inhalt des gegebenen Arguments.

1) Kopierzuweisungsoperator. Ersetzt den Inhalt durch eine Kopie des Inhalts von other . Ruft effektiv c = other. c ; comp = other. comp ; auf.
2) Move-Zuweisungsoperator. Ersetzt die Inhalte durch die von other unter Verwendung von Move-Semantik. Ruft effektiv c = std :: move ( other. c ) ; comp = std :: move ( other. comp ) ; auf.
3) Ersetzt den Inhalt durch den durch die Initialisiererliste ilist identifizierten Inhalt.

Inhaltsverzeichnis

Parameter

other - ein weiterer Container-Adapter, der als Quelle verwendet werden soll
ilist - Initialisierungsliste, die als Quelle verwendet werden soll

Rückgabewert

* this

Komplexität

1,2) Entspricht dem operator = des zugrundeliegenden Containers.
3) Linear in der Größe von * this und ilist .

Beispiel

#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("Anfangs:");
    std::println("x = {}", x);
    std::println("y = {}", y);
    std::println("z = {}", z);
    y = x; // Überladung (1)
    std::println("Kopierzuweisung kopiert Daten von x nach y:");
    std::println("x = {}", x);
    std::println("y = {}", y);
    z = std::move(x); // Überladung (2)
    std::println("Move-Zuweisung verschiebt Daten von x nach z und modifiziert sowohl x als auch z:");
    std::println("x = {}", x);
    std::println("z = {}", z);
    z = w; // Überladung (3)
    std::println("Zuweisung der initializer_list w an z:");
    std::println("w = {}", w);
    std::println("z = {}", z);
}

Ausgabe:

Anfangs:
x = {1: 1, 2: 2, 3: 3}
y = {}
z = {}
Kopierzuweisung kopiert Daten von x nach y:
x = {1: 1, 2: 2, 3: 3}
y = {1: 1, 2: 2, 3: 3}
Move-Zuweisung verschiebt Daten von x nach z und modifiziert sowohl x als auch z:
x = {}
z = {1: 1, 2: 2, 3: 3}
Zuweisung der initializer_list w an z:
w = {4: 4, 5: 5, 6: 6, 7: 7}
z = {4: 4, 5: 5, 6: 6, 7: 7}

Siehe auch

Konstruiert den flat_multimap
(öffentliche Elementfunktion)
Ersetzt die zugrunde liegenden Container
(öffentliche Elementfunktion)