
Kevin Heifner wrote:
Sumanth,
Comparison operators are defined in tuple_comparison.hpp
Sumanth J.V wrote:
#include "boost/tuple/tuple_io.hpp"
// add this line #include "boost/tuple/tuple_comparison.hpp"
#include <vector> #include <algorithm>
typedef boost::tuple
Task; typedef std::vector<Task> TaskSet; // remove these // bool operator<(const Task& a, const Task& b) { // return boost::get<1>(a) < boost::get<1>(b); // }
int main(int argc, char** argv) { TaskSet ts;
ts.push_back( boost::make_tuple(0, 0, 0, 0) ); ts.push_back( boost::make_tuple(3, 3, 3, 3) ); ts.push_back( boost::make_tuple(2, 2, 2, 2) );
std::sort(ts.begin(), ts.end());
return 0; }
KevinH
Thanx Kevin, Now my code compiles. However, I would like to change the default behavior of the comparison operator. From the boost documentation, "the operators <, >, <= and >= implement a lexicographical ordering". But I would like comparison to be based only on the second element of the tuple. Is there anyway this can be implemented? cheers sumanth