Espaços nominais
Variantes
Acções

std::tuple::swap

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

 
 
Biblioteca de utilitários
Digite apoio (basic types, RTTI, type traits)
Gerenciamento de memória dinâmica
De tratamento de erros
Utilidades do programa
Variadic funções
Data e hora
Objetos de função
(C++11)
Os operadores relacionais
Original:
Relational operators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rel_ops::operator!=
rel_ops::operator>
rel_ops::operator<=
rel_ops::operator>=
Pares e tuplas
Original:
Pairs and tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
Troque, avançar e avançar
Original:
Swap, forward and move
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
(C++11)
(C++11)
 
std::tuple
Funções de membro
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
Não-membros funções
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.
Classes auxiliares
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.
 
Definido no cabeçalho <tuple>
void swap( tuple& other );
(desde C++11)
Chama std::swap para cada elemento em *this e seu elemento correspondente em 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.

Índice

[editar] Parâmetros

other -
tupla de valores para trocar
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

(Nenhum)
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] Exceções

noexcept specification:  (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] Exemplo

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

Saída:

(10, test, 3.14)

[editar] Veja também