Tuple how to get the TYPE of the n-th element?

Hi I working with tuples, and that tuples are constructed by K elements. For me interesting are 1-st, 2-nd and 3-rd. 0-th and others not. Inside my procedure I want to know what are the types on the positions 1, 2, 3. How can I get them? The example: somewhere in the code: typedef tuple < std::string, double, double, double, int, std::string > Foo; typedef tuple < std::string, long double, long double, long double, long , std::map<int,std::string> > Bar; My part: template < typename Tuple > // somethink like: typename Tuple::get_type<1> calculate ( Tuple & t ) { // here I need for some calculations know what are the types // on the positions 1,2,3? }; And proposition of usage: calculate ( /*Foo*/ foo ); calculate ( /*Bar*/ bar ); Best regards, -- |\/\/| Seweryn Habdank-Wojewódzki `\/\/'

Hello, See http://www.boost.org/libs/tuple/doc/tuple_advanced_interface.html Basically the metafunction boost::tuples::element<N, T>::type gives you the type of the N'th element of the tuple type T. Benjamin Lau

Hi Benjamin Lau wrote:
Hello,
See http://www.boost.org/libs/tuple/doc/tuple_advanced_interface.html
Basically the metafunction boost::tuples::element<N, T>::type gives you the type of the N'th element of the tuple type T.
Thanks a lot. I have not seen this link :-). Best regards, -- |\/\/| Seweryn Habdank-Wojewódzki `\/\/'
participants (2)
-
Benjamin Lau
-
Seweryn Habdank-Wojewódzki