A specialization for this class template also exists for the tuple-like types array and pair in their respective headers, also inheriting from integral_constant with member value defined to the appropriate constexpr value.
Template parameters
T
Type for which the tuple size is to be obtained.
This shall be a class for which a specialization of this class exists, such as a tuple, and tuple-like classes array and pair.
Member types
member type
definition
value
The number of elements in the tuple or tuple-like object.
This is a constexpr value of the unsigned integral type size_t.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// tuple_size
#include <iostream>
#include <tuple>
int main ()
{
std::tuple<int,char,double> mytuple (10,'a',3.14);
std::cout << "mytuple has ";
std::cout << std::tuple_size<decltype(mytuple)>::value;
std::cout << " elements." << std::endl;
return 0;
}