다음을 통해 공유


swap(map)

두 맵 개체의 요소를 교환합니다.

template<class _Key, class _Ty, class _Pr, class _Alloc>
void swap(
   map<Key, Traits, Compare, Alloctor >& _Left,
   map<Key, Traits, Compare, Alloctor >& _Right
);

매개 변수

  • _Right
    The map providing the elements to be swapped, or the map whose elements are to be exchanged with those of the map _Left.

  • _Left
    The map whose elements are to be exchanged with those of the map _Right.

설명

The template function is an algorithm specialized on the container class map to execute the member function _Left.swap(_Right). This is an instance of the partial ordering of function templates by the compiler. 템플릿 함수가 함수 호출이 있는 템플릿 일치가 고유하지 않게 초과 로드되면 컴파일러는 템플릿 함수의 가장 특수화된 버전을 선택합니다. The general version of the template function, template <class T> void swap(T&, T&), in the algorithm class works by assignment and is a slow operation. 각 컨테이너에 있는 특수화된 버전은 컨테이너 클래스의 내부 표현을 사용하여 작업할 수 있는 것만큼 훨씬 빠릅니다.

예제

See the code example for member function map::swap for an example that uses the template version of swap.

요구 사항

헤더: <맵>

네임스페이스: std

참고 항목

참조

표준 템플릿 라이브러리