◐ Shell
clean mode source ↗

std::swap - cppreference.com

Da cppreference.com.

Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.

La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui.

Click here for the English version of this page

<metanoindex/>

<tbody> </tbody>

Elemento definito nell'header

<algorithm>

Elemento definito nell'header

<utility>

(fino al c++11)
(dal 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) (dal C++11)

Scambi i valori indicati.

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)

Scambia i valori a e 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)

Swap gli array a e b. In effetti le chiamate std::swap_ranges(a, a+N, b).

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.

Parametri

a, b -

i valori da scambiare

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.

Valore di ritorno

(Nessuno)

Original:

(none)

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

Eccezioni

1)

noexcept

specification:  (dal C++11)

<tbody> </tbody>

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

2)

noexcept

specification:  (dal C++11)

<tbody> </tbody>

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

Complessità

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)

Lineare 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.

Specializzazioni

Entrambi i corsi sono personalizzati e sovraccarichi dell'algoritmo std::swap sono permessi, ma i sovraccarichi sono in genere preferito dal specializzazioni di un modello di funzione non sono ammessi per le classi template. Le funzioni di libreria utilizzare sempre fornito dall'utente sovraccarichi durante lo scambio, se si trovano per argomento-dipendente di ricerca (come da concetto Swappable).

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.

Gli overload che seguono sono già fornite dalla libreria standard:

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.

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]
specializza l'algoritmo std::swap
(funzione di modello) [modifica]

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap()

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.


(funzione di modello)

specializzata l'algoritmo std::swap()

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.


(funzione di modello)

specializzata l'algoritmo std::swap()

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.


(funzione di modello)

specializzata l'algoritmo std::swap()

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.


(funzione di modello)

specializzata l'algoritmo std::swap()

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.


(funzione di modello)

specializzata l'algoritmo std::swap()

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.


(funzione di modello)

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap()

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.


(funzione di modello)

specializzata l'algoritmo std::swap()

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.


(funzione di modello)

specializzata l'algoritmo std::swap

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.


(funzione di modello) [modifica]

specializzata l'algoritmo std::swap()

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.


(funzione di modello)

specializzata l'algoritmo std::swap()

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.


(funzione di modello)

specializzata l'algoritmo std::swap()

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.


(funzione di modello)

Esempio

Vedi anche

swap gli elementi a cui punta due iteratori

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.


(funzione di modello) [modifica]

Scambia due gamme di elementi

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.


(funzione di modello) [modifica]