std::swap
De cppreference.com
<tbody>
</tbody>
| Dclar dans l'en-tte <algorithm>
Dclar dans l'en-tte <utility> |
(avant C++11) (depuis 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) | (depuis C++11) |
change les valeurs donnes.
1) changes les valeurs a et b.
2) Echange les tableaux a et b. Pour cela, appelle std::swap_ranges(a, a+N, b).
Paramtres
| a, b | - | les valeurs permuter |
| Type requirements | ||
-T must meet the requirements of MoveAssignable and MoveConstructible.
| ||
-T2 must meet the requirements of Swappable.
| ||
Retourne la valeur
Aucune
Exceptions
1)
noexcept specification: (depuis C++11)
<tbody>
</tbody>
noexcept(noexcept( std::is_nothrow_move_constructible<T>::value && std::is_nothrow_move_assignable<T>::value )) |
||
2)
Complexit
1)
Constante
Original:
Constant
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
2)
Linaire en 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.
You can help to correct and verify the translation. Click here for instructions.
Spcialisations
Il est autoris la fois de surcharger et de spcialiser l'algorithme std::swap, mais les surcharges sont gnralement prfres car les spcialisations d'un modle de fonction ne sont pas autorises pour les classes template. Les fonctions de la bibliothque standard utilisent toujours les surcharges fournies par l'utilisateur lors du swap, si elles sont reconnues lors de la recherche des argument (d'aprs le concept Swappable).
Les surcharges suivantes sont dj fournies par la bibliothque standard :
(C++11) |
l'algorithme spcialis 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. (fonction gnrique) |
(C++11) |
l'algorithme spcialis 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. (fonction gnrique) |
(C++11) |
l'algorithme spcialis 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. (fonction gnrique) |
(C++11) |
l'algorithme spcialis 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. (fonction gnrique) |
(C++11) |
l'algorithme spcialis 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. (fonction gnrique) |
(C++11) |
permet de spcialiser l'algorithme std::swap (fonction gnrique) |
l'algorithme spcialis 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. (fonction gnrique) | |
l'algorithme spcialis 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. (fonction gnrique) | |
l'algorithme spcialis 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. (fonction gnrique) | |
l'algorithme spcialis 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. (fonction gnrique) | |
l'algorithme spcialis 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. (fonction gnrique) | |
l'algorithme spcialis 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. (fonction gnrique) | |
l'algorithme spcialis 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. (fonction gnrique) | |
l'algorithme spcialis 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. (fonction gnrique) | |
l'algorithme spcialis 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. (fonction gnrique) | |
l'algorithme spcialis 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. (fonction gnrique) | |
l'algorithme spcialis 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. (fonction gnrique) | |
l'algorithme spcialis 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. (fonction gnrique) | |
l'algorithme spcialis 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. (fonction gnrique) | |
l'algorithme spcialis 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. (fonction gnrique) | |
l'algorithme spcialis 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. (fonction gnrique) | |
l'algorithme spcialis 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. (fonction gnrique) | |
l'algorithme spcialis 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. (fonction gnrique) | |
(C++11) |
spcialise l'algorithme std::swap() (fonction gnrique) |
(C++11) |
spcialise l'algorithme std::swap() (fonction gnrique) |
spcialise l'algorithme std::swap() (fonction gnrique) | |
spcialise l'algorithme std::swap() (fonction gnrique) | |
spcialise l'algorithme std::swap() (fonction gnrique) | |
(C++11) |
spcialise l'algorithme std::swap() (fonction gnrique) |
(C++11) |
l'algorithme spcialis 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. (fonction gnrique) |
(C++11) |
l'algorithme spcialis 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. (fonction gnrique) |
(C++11) |
l'algorithme spcialis 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. (fonction gnrique) |
(C++11) |
spcialise l'algorithme std::swap() (fonction gnrique) |
(C++11) |
spcialise l'algorithme std::swap() (fonction gnrique) |
(C++11) |
l'algorithme spcialis 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. (fonction gnrique) |
(C++11) |
spcialise l'algorithme std::swap() (fonction gnrique) |
(C++11) |
spcialise l'algorithme std::swap() (fonction gnrique) |
(C++11) |
spcialise l'algorithme std::swap() (fonction gnrique) |
Exemple
| This section is incomplete Reason: no example |
Voir aussi
permute les lments points par deux itrateurs 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. (fonction gnrique) | |
swaps de deux gammes d'lments 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. (fonction gnrique) | |