I have some code that looks like this:
typedef tuple<int, int, double> DataPoint;
vector<DataPoint> data;
vector<double> third_column_only;
// Code to read in data goes here.
transform(data.begin(), data.end(), back_inserter(values), tuples::get<1, DataPoint>);
Unfortunately, the last line doesn't compile - it gives me a message like this:
/path/to/boost/tuple/detail/tuple_basic.hpp: In instantiation of `boost::tuples::cons': /path/to/boost/tuple/detail/tuple_basic.hpp:144: instantiated from `boost::tuples::element >' program.cc:33: instantiated from here /path/to/boost/tuple/detail/tuple_basic.hpp:329: error: `boost::tuples::cons::tail' has incomplete type /path/to/boost/tuple/detail/tuple_basic.hpp:329: error: invalid use of template type parameter /path/to/boost/tuple/detail/tuple_basic.hpp:151: confused by earlier errors, bailing out
Basically, to use Python's operator.itemgetter function, I want to do something like this:
transform(data.begin(), data.end(), back_inserter(values), itemgetter(2))
How can I do that using Boost?