Espacios de nombres
Variantes

std::tuple::swap

De cppreference.com
 
 
Biblioteca de servicios
Apoyo del lenguaje
Apoyo de tipos (tipos básicos, RTTI)
Macros de prueba de característica de la biblioteca (C++20)
Servicios de programa
Funciones variádicas
Apoyo de corrutinas (C++20)
Apoyo de contratos (C++26)
Comparación de tres vías (C++20)
(C++20)
(C++20)(C++20)(C++20)  
(C++20)(C++20)(C++20)

 
 
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.

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.

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.

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&>())) &&
    ...
)

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)

Ver también

Morty Proxy This is a proxified and sanitized view of the page, visit original site.