Charles Salvia
Charles Salvia

Reputation: 53319

C++: Element types in a tuple

std::pair has the nested typedefs first_type and second_type which give the type of the first and second element respectively.

But is there any way to statically determine the type of the Nth element in a boost::tuple (or std::tuple in C++0x)? I know I could create my own template with N as a parameter, and use it to recursively traverse the cons list of the tuple, but is there a standard way of doing this?

Upvotes: 0

Views: 1307

Answers (1)

sellibitze
sellibitze

Reputation: 28107

http://www.boost.org/doc/libs/1_40_0/libs/tuple/doc/tuple_advanced_interface.html

In C++0x it will work similarly. But I think it has been renamed to tuple_element<I,T>::type

Upvotes: 1

Related Questions