The type of overloads get<0> you want:
const std::string& (*)(const boost::tuples::cons<std::string, boost::tuples::cons<int, boost::tuples::null_type> >&)
If you typedef to get0_fn_t , then you can declare a pointer to this overload get<0> with:
get0_fn_t getter_fn = &boost::tuples::get<0, std::string, boost::tuples::cons<int, boost::tuples::null_type> >;
EDIT: This program is a complete working example:
#include <algorithm> #include <cstdlib> #include <iostream> #include <iterator> #include <string> #include <vector> #include <boost/bind.hpp> #include <boost/tuple/tuple.hpp> int main() { typedef boost::tuple<std::string, int> tuple_type; std::vector<tuple_type> tuples; tuples.push_back(boost::make_tuple(std::string("test3"), 3)); tuples.push_back(boost::make_tuple(std::string("test0"), 0)); std::vector<std::string> strings; typedef const std::string& (*get0_fn_t)(const boost::tuples::cons<std::string, boost::tuples::cons<int, boost::tuples::null_type> >&); get0_fn_t getter_fn = &boost::tuples::get<0, std::string, boost::tuples::cons<int, boost::tuples::null_type> >; std::transform(tuples.begin(), tuples.end(), std::back_insert_iterator<std::vector<std::string> >(strings), getter_fn); std::vector<std::string>::const_iterator it, end = strings.end(); for (it = strings.begin(); it != end; ++it) std::cout << *it << std::endl; return EXIT_SUCCESS; }
EDIT2: This shows how to integrate it into the TestClass template:
template <typename T> class TestClass { private: typedef boost::tuple<std::string, T> PairType; std::vector<PairType> storage; public: void extract(std::vector<std::string>& result) const { result.clear(); typedef const std::string& (*get0_fn_t)(const boost::tuples::cons<std::string, boost::tuples::cons<T, boost::tuples::null_type> >&); get0_fn_t getter_fn = &boost::tuples::get<0, std::string, boost::tuples::cons<T, boost::tuples::null_type> >; std::transform(storage.begin(), storage.end(), result.begin(), getter_fn); } };