std::tuple::tuple - cppreference.com
Da cppreference.com.
|
|
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate. La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
<metanoindex/>
<tbody> </tbody>
| Elemento definito nell'header <tuple> |
||
|
|
(1) | (dal C++11) |
|
|
(2) | (dal C++11) |
|
|
(3) | (dal C++11) |
|
|
(4) | (dal C++11) |
|
|
(5) | (dal C++11) |
|
|
(6) | (dal C++11) |
|
|
(7) | (dal C++11) |
|
|
(8) | (dal C++11) |
|
|
(9) | (dal C++11) |
|
|
(10) | (dal C++11) |
|
|
(11) | (dal C++11) |
|
|
(12) | (dal C++11) |
|
|
(13) | (dal C++11) |
|
|
(14) | (dal C++11) |
|
|
(15) | (dal C++11) |
|
|
(16) | (dal C++11) |
|
|
(17) | (dal C++11) |
|
|
(18) | (dal C++11) |
Costruisce una nuova tupla.
Original:
Constructs a new tuple.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
1)
Costruttore di default. Valore-inizializza tutti gli elementi.
Original:
Default constructor. Value-initializes all elements.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
Inizializza ogni elemento della tupla con il parametro corrispondente.
Original:
Initializes each element of the tuple with the corresponding parameter.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3)
Inizializza ogni elemento della tupla con il valore corrispondente in std::forward<Utypes>(args).
Original:
Initializes each element of the tuple with the corresponding value in std::forward<Utypes>(args).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
4)
Per ogni i in sizeof...(UTypes), inizializza-esimo elemento della tupla con std::get<i>(other).
Original:
For all i in sizeof...(UTypes), initializes ith element of the tuple with std::get<i>(other).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
5)
Per ogni i in sizeof...(UTypes), inizializza-esimo elemento della tupla con std::forward<Ui>(std::get<i>(other)).
Original:
For all i in sizeof...(UTypes), initializes ith element of the tuple with std::forward<Ui>(std::get<i>(other)).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
6)
Costruisce un 2-elemento tupla con il primo elemento costruito p.first e il secondo elemento dal p.second
Original:
Constructs a 2-element tuple with the first element constructed from p.first and the second element from p.second
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
7)
Costruisce un 2-elemento tupla con il primo elemento costruito std::forward<U1>(p.first) e il secondo elemento dal std::forward<U2>(p.second)
Original:
Constructs a 2-element tuple with the first element constructed from std::forward<U1>(p.first) and the second element from std::forward<U2>(p.second)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
8)
Generato dal compilatore costruttore di copia. Inizializza ogni elemento della tupla con l'elemento corrispondente di other
Original:
Compiler-generated copy constructor. Initializes each element of the tuple with the corresponding element of other
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
9)
Generato dal compilatore costruttore mossa. Inizializza ogni elemento i-esimo della tupla con std::forward<Ui>(std::get<i>(other)).
Original:
Compiler-generated move constructor. Initializes each ith element of the tuple with std::forward<Ui>(std::get<i>(other)).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
10 - 18) Identico a 1-9 se non ogni elemento è stato creato da uso-allocatore di costruzione, che viene, viene passato l'oggetto a Allocator come un ulteriore argomento al costruttore di ogni elemento per il quale è std::uses_allocator<Ui, Alloc>::value true.
Original:
10 - 18) Identical to 1-9 except each element is created by uses-allocator construction, that is, the Allocator object a is passed as an additional argument to the constructor of each element for which std::uses_allocator<Ui, Alloc>::value is true.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Parametri
| args | - | valori utilizzati per inizializzare ogni elemento della tupla Original: values used to initialize each element of the tuple The text has been machine-translated via Google Translate. |
| other | - | una tupla di valori utilizzati per inizializzare ogni elemento del tupe Original: a tuple of values used to initialize each element of the tupe The text has been machine-translated via Google Translate. |
| p | - | coppia di valori utilizzati per inizializzare entrambi gli elementi di questa 2-tupla Original: pair of values used to initialize both elements of this 2-tuple The text has been machine-translated via Google Translate. |
| a | - | allocatore di utilizzare in applicazioni-allocatore di costruzione Original: allocator to use in uses-allocator construction The text has been machine-translated via Google Translate. |
Esempio
#include <iostream> #include <string> #include <vector> #include <tuple> #include <memory> // 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, double> t1; std::cout << "Value-initialized: "; print(t1); std::tuple<int, std::string, double> t2(42, "Test", -3.14); std::cout << "Initialized with values: "; print(t2); std::tuple<char, std::string, int> t3(t2); std::cout << "Implicitly converted: "; print(t3); std::tuple<int, double> t4(std::make_pair(42, 3.14)); std::cout << "Constructed from a pair"; print(t4); // given Allocator my_alloc with a single-argument constructor my_alloc(int) // use my_alloc(1) to allocate 10 ints in a vector std::vector<int, my_alloc> v(10, 1, my_alloc(1)); // use my_alloc(2) to allocate 10 ints in a vector in a tuple std::tuple<int, std::vector<int, my_alloc>, double> t5(std::allocator_arg, my_alloc(2), 42, v, -3.14); }
Output:
Value-initialized: (0, , 0) Initialized with values: (42, Test, -3.14) Implicitly converted: (*, Test, -3) Constructed from a pair(42, 3.14)
Vedi anche
crea un oggetto Original: creates a The text has been machine-translated via Google Translate. (funzione di modello) [modifica] | |
crea un Original: creates a The text has been machine-translated via Google Translate. (funzione di modello) [modifica] | |
crea un Original: creates a The text has been machine-translated via Google Translate. (funzione di modello) [modifica] | |