Defined in header <tuple> | ||||
---|---|---|---|---|
| (1) | (since C++11) | ||
| (2) | (since C++11) | ||
Defined in header <tuple> | ||||
(since C++17) (since C++17) | ||||
| (3) | (since C++11) | ||
| (4) | (since C++11) | ||
| (5) | (since C++11) |
Provides compile-time indexed access to the types of the elements of the tuple.
Member types
Member type | Definition |
---|---|
type | the type of I th element of the tuple, where I is in [0, sizeof...(Types)) |
Helper types
| (since C++14) |
Possible implementation
|
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #include <iostream> #include <tuple> template < class ... Args> struct type_list { template <std:: size_t N> using type = typename std::tuple_element<N, std::tuple<Args...>>::type; }; int main() { std::cout << std::boolalpha; type_list< int , char , bool >::type<2> x = true ; std::cout << x << '\n' ; } |
Output:
1 | true |
See also
obtains the type of the elements of array (class template specialization) | |
(C++11) | obtains the type of the elements of pair (class template specialization) |
Please login to continue.