std::tuple_size<std::pair>
De cppreference.com
<tbody>
</tbody>
| Déclaré dans l'en-tête <utility>
|
||
template< class T1, class T2 > struct tuple_size<std::pair<T1, T2>>; |
(depuis C++11) | |
La spécialisation partielle de
std::tuple_size de paires fournit un moyen de compilation pour obtenir le nombre d'éléments dans une paire, qui est toujours 2, en utilisant une syntaxe tuple .Original:
The partial specialization of
std::tuple_size for pairs provides a compile-time way to obtain the number of elements in a pair, which is always 2, using tuple-like syntax.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.
Original: Members The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
value [ statique ]Original: static The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
solidaire de valeur constante 2 Original: integral constant with value 2 The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (constante membre statique publique) |
Exemple
#include <iostream>
#include <utility>
#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));
test(std::make_pair(1, 3.14));
}
Résultat :
3
2
Voir aussi
obtient la taille de tuple au moment de la compilation Original: obtains the size of tuple at compile time The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (classe générique spécialisée) | |
obtient la taille d'une 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 générique spécialisée) | |
(C++11) |
obtient le type des éléments de pair Original: obtains the type of the elements of pair The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (classe générique spécialisée) |