◐ Shell
clean mode source ↗

std::swap – cppreference.com

<metanoindex/>

<tbody> </tbody>

definiert in Header

<algorithm>

definiert in header

<utility>

(bis C + +11)
(seit C++11)

template< class T > void swap( T& a, T& b );

(1)

template< class T2, size_t N > void swap( T2 (&a)[N], T2 (&b)[N]);

(2) (seit C++11)

Tauscht die übergebenen Werte.

Original:

Exchanges the given values.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

1)

Tauscht die Werte a und b .

Original:

Swaps the values a and b.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

2)

Tauscht die Arrays a und b. Ruft std::swap_ranges(a, a+N, b) auf.

Original:

Swaps the arrays a and b. In effect calls std::swap_ranges(a, a+N, b).

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Parameter

a, b -

die zu tauschenden Werte

Original:

the values to be swapped

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Type requirements
-T must meet the requirements of MoveAssignable and MoveConstructible.
-T2 must meet the requirements of Swappable.

Rückgabewert

(None)

Original:

(none)

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Ausnahmen

1)

noexcept

specification:  (seit C++11)

<tbody> </tbody>

noexcept(noexcept( std::is_nothrow_move_constructible<T>::value && std::is_nothrow_move_assignable<T>::value ))

2)

noexcept

specification:  (seit C++11)

<tbody> </tbody>

noexcept(noexcept(swap(*a, *b)))

Komplexität

1)

Constant

Original:

Constant

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

2)

Linear in N

Original:

Linear in N

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Spezialisierungen

Es sind sowohl benutzerdefinierte Spezialisierungen als auch Überladungen des std::swap Algorithmus erlaubt. Überladungen sind in der Regel vorzuziehen, da Spezialisierungen eines Funktions-Template für Template-Klassen nicht erlaubt sind. Library-Funktionen nutzen immer die vom Benutzer bereitgestellten Überladungen, falls sie durch Deduktion der Argumente (nach Swappable Konzept) gefunden werden können.

Original:

Both custom specializations and overloads of the std::swap algorithm are allowed, but the overloads are generally preferred since specializations of a function template aren't allowed for template classes. Library functions always use the user-provided overloads when swapping, if they are found by argument-dependent lookup (as per Swappable concept).

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Die folgenden Überladungen werden bereits von der Standard-Bibliothek zur Verfügung gestellt:

Original:

The following overloads are already provided by the standard library:

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

spezialisiert die std::swap Algorithmus

Original:

specializes the std::swap algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template) [edit]

spezialisiert den std::swap Algorithmus

Original:

specializes the std::swap algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template) [edit]
Spezialisierung des std::swap-Algorithmus für verteilte Zeiger
(Funktions-Template) [edit]
Spezialisierung des std::swap-Algorithmus für schwache Zeiger
(Funktions-Template) [edit]
Spezialisierung des std::swap-Algorithmus für Zeiger mit explizitem Besitz
(Funktions-Template) [edit]
spezialisiert den std::swap Algorithmus
(Funktions-Template) [edit]

spezialisiert die std::swap Algorithmus

Original:

specializes the std::swap algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template) [edit]

spezialisiert die std::swap Algorithmus

Original:

specializes the std::swap algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template) [edit]

spezialisiert die std::swap Algorithmus

Original:

specializes the std::swap algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template) [edit]

spezialisiert die std::swap Algorithmus

Original:

specializes the std::swap algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template) [edit]

spezialisiert die std::swap Algorithmus

Original:

specializes the std::swap algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template) [edit]

spezialisiert die std::swap Algorithmus

Original:

specializes the std::swap algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template) [edit]

spezialisiert die std::swap Algorithmus

Original:

specializes the std::swap algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template) [edit]

spezialisiert die std::swap Algorithmus

Original:

specializes the std::swap algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template) [edit]

spezialisiert die std::swap Algorithmus

Original:

specializes the std::swap algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template) [edit]

spezialisiert die std::swap Algorithmus

Original:

specializes the std::swap algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template) [edit]

spezialisiert die std::swap Algorithmus

Original:

specializes the std::swap algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template) [edit]

spezialisiert die std::swap Algorithmus

Original:

specializes the std::swap algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template) [edit]

spezialisiert die std::swap Algorithmus

Original:

specializes the std::swap algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template) [edit]

spezialisiert die std::swap Algorithmus

Original:

specializes the std::swap algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template) [edit]

spezialisiert die std::swap Algorithmus

Original:

specializes the std::swap algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template) [edit]

spezialisiert die std::swap Algorithmus

Original:

specializes the std::swap algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template) [edit]

spezialisiert die std::swap Algorithmus

Original:

specializes the std::swap algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template) [edit]

spezialisiert die std::swap() Algorithmus

Original:

specializes the std::swap() algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template)

spezialisiert die std::swap() Algorithmus

Original:

specializes the std::swap() algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template)

spezialisiert die std::swap() Algorithmus

Original:

specializes the std::swap() algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template)

spezialisiert die std::swap() Algorithmus

Original:

specializes the std::swap() algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template)

spezialisiert die std::swap() Algorithmus

Original:

specializes the std::swap() algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template)

spezialisiert die std::swap() Algorithmus

Original:

specializes the std::swap() algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template)

spezialisiert die std::swap Algorithmus

Original:

specializes the std::swap algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template) [edit]

spezialisiert die std::swap Algorithmus

Original:

specializes the std::swap algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template) [edit]

spezialisiert die std::swap Algorithmus

Original:

specializes the std::swap algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template) [edit]

spezialisiert die std::swap() Algorithmus

Original:

specializes the std::swap() algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template)

spezialisiert die std::swap() Algorithmus

Original:

specializes the std::swap() algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template)
Spezialisierung des std::swap Algorithmus
(Funktions-Template) [edit]

spezialisiert die std::swap() Algorithmus

Original:

specializes the std::swap() algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template)

spezialisiert die std::swap() Algorithmus

Original:

specializes the std::swap() algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template)

spezialisiert die std::swap() Algorithmus

Original:

specializes the std::swap() algorithm

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template)

Beispiel

Siehe auch

Swaps die Elemente, auf die zwei Iteratoren

Original:

swaps the elements pointed to by two iterators

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template) [edit]

Swaps zwei Bereiche von Elementen

Original:

swaps two ranges of elements

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(Funktions-Template) [edit]