Namespaces
Variants

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

From cppreference.net

flat_multimap & operator = ( const flat_multimap & other ) ;
(1) (C++23 이후)
(암시적으로 선언됨)
flat_multimap & operator = ( flat_multimap && other ) ;
(2) (C++23 이후)
(암시적으로 선언됨)
flat_multimap & operator = ( std:: initializer_list < value_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_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("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: 1, 2: 2, 3: 3}
y = {}
z = {}
Copy assignment copies data from x to y:
x = {1: 1, 2: 2, 3: 3}
y = {1: 1, 2: 2, 3: 3}
Move assignment moves data from x to z, modifying both x and z:
x = {}
z = {1: 1, 2: 2, 3: 3}
Assignment of initializer_list w to z:
w = {4: 4, 5: 5, 6: 6, 7: 7}
z = {4: 4, 5: 5, 6: 6, 7: 7}

참고 항목

flat_multimap 을 생성합니다
(public member function)
기반 컨테이너들을 교체합니다
(public member function)