std::tuple_size<std::tuple>
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>
|
||
template< class T > class tuple_size; /*undefined*/ |
(1) | (dal C++11) |
template< class... Types > class tuple_size<tuple<Types...> > : public std::integral_constant<std::size_t, sizeof...(Types)> { }; |
(2) | (dal C++11) |
template< class T > class tuple_size<const T> : public std::integral_constant< typename std::remove_cv<decltype(std::tuple_size<T>::value)>::type, std::tuple_size<Tp>::value> { }; |
(3) | (dal C++11) |
template< class T > class tuple_size< volatile T > : public std::integral_constant< typename std::remove_cv<decltype(std::tuple_size<T>::value)>::type, std::tuple_size<Tp>::value> { }; |
(4) | (dal C++11) |
template< class T > class tuple_size< const volatile T > : public std::integral_constant< typename std::remove_cv<decltype(std::tuple_size<T>::value)>::type, std::tuple_size<Tp>::value> { }; |
(5) | (dal C++11) |
Consente di accedere al numero di elementi in una tupla come un tempo di compilazione espressione costante.
Original:
Provides access to the number of elements in a tuple as a compile-time constant expression.
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.
Inherited from std::integral_constant
Member constants
value [statico] |
sizeof...(Types) (pubblico membro statico costante) |
Member functions
operator std::size_t |
converte l'oggetto in std::size_t, restituisce value Original: converts the object to std::size_t, returns value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) |
Member types
Tipo
Original: Type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
value_type
|
std::size_t
|
type
|
std::integral_constant<std::size_t, value>
|
Esempio
#include <iostream>
#include <tuple>
template<class T>
void test(T t)
{
int a[std::tuple_size<T>::value]; // can be used at compile time
std::cout << std::tuple_size<T>::value << '\n'; // or at run time
}
int main()
{
test(std::make_tuple(1, 2, 3.14));
}
Output:
3
Vedi anche
ottiene la dimensione di un array Original: obtains the size of an array The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (classe modello di specializzazione) | |
(C++11) |
ottiene la dimensione di un pair Original: obtains the size of a pair The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (classe modello di specializzazione) |
tupla accede elemento specificato Original: tuple accesses specified element The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione di modello) | |
ottiene il tipo dell'elemento specificato Original: obtains the type of the specified element The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (classe modello di specializzazione) | |