Espaces de noms
Variantes
Affichages
Actions

std::tuple::swap

De cppreference.com
< cpp‎ | utility‎ | tuple

 
 
 
std::tuple
Les fonctions membres
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
tuple::tuple
tuple::operator=
tuple::swap
Tiers fonctions
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
make_tuple
tie
forward_as_tuple
None
operator=
operator!=
operator<
operator<=
operator>
operator>=
std::swap
get
Classes d'aide
Original:
Helper classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
tuple_size
tuple_element
uses_allocator
ignore
 
Déclaré dans l'en-tête <tuple>
void swap( tuple& other );
(depuis C++11)
std::swap demande pour chaque élément dans *this et son élément correspondant dans other .
Original:
Calls std::swap for each element in *this and its corresponding element in other.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Sommaire

[modifier] Paramètres

other -
tuple de valeurs à échanger
Original:
tuple of values to swap
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifier] Retourne la valeur

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

[modifier] Exceptions

noexcept specification:   (depuis C++11)
noexcept(

    noexcept(swap(std::declval<T0&>>(), std::declval<T0&>())) &&
    noexcept(swap(std::declval<T1&>>(), std::declval<T1&>())) &&
    noexcept(swap(std::declval<T2&>>(), std::declval<T2&>())) &&
    ...

)

[modifier] Exemple

#include <iostream>
#include <tuple>
#include <string>
 
int main()
{
    std::tuple<int, std::string, float> p1, p2;
    p1 = std::make_tuple(10, "test", 3.14);
    p2.swap(p1);
    std::cout << "("  << std::get<0>(p2)
              << ", " << std::get<1>(p2)
              << ", " << std::get<2>(p2) << ")\n";
}

Résultat :

(10, test, 3.14)

[modifier] Voir aussi