Espaces de noms
Variantes
Affichages
Actions

std::tuple_size<std::tuple>

De cppreference.com
< cpp‎ | utility‎ | tuple

 
 
 
std::tuple
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.
tuple::tuple
tuple::operator=
tuple::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_tuple
tie
forward_as_tuple
None
operator=
operator!=
operator<
operator<=
operator>
operator>=
std::swap
get
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
tuple_element
uses_allocator
ignore
 
Déclaré dans l'en-tête <tuple>
template< class T >
class tuple_size; /*undefined*/
(1) (depuis C++11)
template< class... Types >

class tuple_size<tuple<Types...> >

 : public std::integral_constant<std::size_t, sizeof...(Types)> { };
(2) (depuis 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) (depuis 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) (depuis 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) (depuis C++11)
Permet d'accéder au nombre d'éléments dans un tuple comme une expression constante de compilation .
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.

Sommaire

Inherited from std::integral_constant

Member constants

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.
]
sizeof...(Types)
(constante membre statique publique)

Member functions

operator std::size_t
convertit l'objet en std::size_t, retourne 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.

(fonction membre publique)

Member types

Type d'
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>

[modifier] Exemple

#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));
}

Résultat :

3

[modifier] Voir aussi

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 la taille d'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 générique spécialisée) [edit]
tuple accède élément spécifié
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.

(fonction générique) [edit]
obtient le type de l'élément spécifié
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 générique spécialisée) [edit]