std::tuple_cat
De cppreference.com
![]() |
Esta página se ha traducido por ordenador/computador/computadora de la versión en inglés de la Wiki usando Google Translate.
La traducción puede contener errores y palabras aparatosas/incorrectas. Planea sobre el texto para ver la versión original. Puedes ayudar a corregir los errores y mejorar la traducción. Para instrucciones haz clic aquí. |
Definido en el archivo de encabezado <tuple>
|
||
template< class... Tuples > tuple<CTypes...> tuple_cat(Tuples&&... args); |
(desde C++11) | |
Construye una tupla que es una concatenación de todas las tuplas de
args
.Original:
Constructs a tuple that is a concatenation of all tuples in
args
.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.
[editar] Parámetros
args | - | cero o más tuplas a concatenar
Original: zero or more tuples to concatenate 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
Un objeto
std::tuple
compuesto por todos los elementos de todas las tuplas de argumentos construidos a partir de std::get<i>(std::forward<Ti>(arg)) para cada elemento individual .Original:
A
std::tuple
object composed of all elements of all argument tuples constructed from std::get<i>(std::forward<Ti>(arg)) for each individual element.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.
[editar] Ejemplo
Ejecuta este código
#include <iostream> #include <tuple> #include <string> // helper function to print a tuple of any size template<class Tuple, std::size_t N> struct TuplePrinter { static void print(const Tuple& t) { TuplePrinter<Tuple, N-1>::print(t); std::cout << ", " << std::get<N-1>(t); } }; template<class Tuple> struct TuplePrinter<Tuple, 1> { static void print(const Tuple& t) { std::cout << std::get<0>(t); } }; template<class... Args> void print(const std::tuple<Args...>& t) { std::cout << "("; TuplePrinter<decltype(t), sizeof...(Args)>::print(t); std::cout << ")\n"; } // end helper function int main() { std::tuple<int, std::string, float> t1(10, "Test", 3.14); int n = 7; auto t2 = std::tuple_cat(t1, std::make_pair("Foo", "bar"), t1, std::tie(n)); n = 10; print(t2); }
Salida:
(10, Test, 3.14, Foo, bar, 10, Test, 3.14, 10)
Crea un objeto de tupla del tipo definido por los tipos de argumentos. (plantilla de función) | |
Crea una tupla de referencias lvalue o desempaca una tupla en objetos individuales. (plantilla de función) | |
Crea una tupla de referencias r-valor. (plantilla de función) |