Espacios de nombres
Variantes
Acciones

std::tuple::swap

De cppreference.com
< cpp‎ | utility‎ | tuple
 
 
Biblioteca de servicios
 
std::tuple
Funciones miembro
tuple::swap
Funciones no miembro
(hasta C++20)(hasta C++20)(hasta C++20)(hasta C++20)(hasta C++20)(C++20)
Guías de deducción(C++17)
Clases asistentes
 
Definido en el archivo de encabezado <tuple>
void swap( tuple& other );
(desde C++11)
std::swap llama para cada elemento en *this y su elemento correspondiente en 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.

Contenido

[editar] Parámetros

other -
tupla de valores a intercambiar
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.

[editar] Valor de retorno

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

[editar] Excepciones

Especificación noexcept:   (desde 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&>())) &&
    ...

)

[editar] Ejemplo

#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";
}

Salida:

(10, test, 3.14)

[editar] Ver también