다음을 통해 공유


swap(set)

Exchanges the elements of two sets.

template<class Key, class Traits, class Allocator> 
void swap( 
   set< Key, Traits, Allocator>& _Left, 
   set< Key, Traits, Allocator>& _Right 
);

매개 변수

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

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

설명

The template function is an algorithm specialized on the container class set 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 the member class set::swap for an example of the use of the template version of swap.

요구 사항

헤더: <설정>

네임스페이스: std

참고 항목

참조

표준 템플릿 라이브러리