Espaces de noms
Variantes
Affichages
Actions

std::tuple_size<std::pair>

De cppreference.com
< cpp‎ | utility‎ | pair
 
 
 
std::pair
Les fonctions membres
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.
pair::pair
pair::operator=
pair::swap
Tiers fonctions
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.
make_pair
operator=
operator!=
operator<
operator<=
operator>
operator>=
std::swap
get (C++11)
Classes d'aide
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.
tuple_size (C++11)
tuple_element (C++11)
 
Defined in header <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.

Membres
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)

[modifier] 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

[modifier] 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) [edit]
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) [edit]
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) [edit]