Namespaces
Variants

std::polymorphic<T, Allocator>:: swap

From cppreference.net
Memory management library
( exposition only* )
Allocators
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Memory resources
Uninitialized storage (until C++20)
( until C++20* )
( until C++20* )
( until C++20* )

Garbage collector support (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
constexpr void swap ( polymorphic & other ) noexcept ( /* see below */ ) ;
(C++26부터)

내용을 other 와 교환합니다.

아래 설명에서, swap_allocators std:: allocator_traits < Allocator > :: propagate_on_container_swap :: value 를 의미합니다.

* this other 의 상태를 교환하며, 소유한 객체 또는 무값 상태를 서로 바꿉니다.

  • 만약 swap_allocators true 이면, using std:: swap ;
    swap ( alloc  , other. alloc  ) ;
    을 실행합니다.
  • 그렇지 않으면, 할당자(allocators)는 교환되지 않습니다.

다음 조건 중 하나라도 충족되면, 동작은 정의되지 않습니다:

  • swap_allocators true 이고, Allocator Swappable 요구 사항을 충족하지 않는 경우.
  • swap_allocators false 이고, get_allocator ( ) == other. get_allocator ( ) false 인 경우.

목차

매개변수

other - 내용을 교환할 polymorphic 객체

예외

noexcept 명세:
noexcept ( std:: allocator_traits < Allocator > :: propagate_on_container_swap :: value
|| std:: allocator_traits < Allocator > :: is_always_equal :: value )

예제

참고 항목

std::swap 알고리즘을 특수화함
(함수 템플릿)