Namespaces
Variants

std::indirect<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 ( indirect & other ) noexcept ( /* siehe unten */ ) ;
(seit C++26)

Tauscht die Inhalte mit denen von other .

In der folgenden Beschreibung bezieht sich swap_allocators auf std:: allocator_traits < Allocator > :: propagate_on_container_swap :: value .

Tauscht die Zustände von * this und other aus, wobei besessene Objekte oder zustandslose Zustände ausgetauscht werden.

  • Wenn swap_allocators den Wert true hat, dann führt es using std:: swap ;
    swap ( alloc  , other. alloc  ) ;
    aus.
  • Andernfalls werden die Allokatoren nicht ausgetauscht.

Wenn eine der folgenden Bedingungen erfüllt ist, ist das Verhalten undefiniert:

  • swap_allocators ist true , und Allocator erfüllt nicht die Anforderungen von Swappable .
  • swap_allocators ist false , und get_allocator ( ) == other. get_allocator ( ) ist false .

Inhaltsverzeichnis

Parameter

other - das indirect Objekt, mit dem die Inhalte ausgetauscht werden sollen

Exceptions

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

Beispiel

Siehe auch

spezialisiert den std::swap Algorithmus
(Funktions-Template)