Boost logo

Boost Users :

From: Sumanth J.V (sumanth_at_[hidden])
Date: 2005-11-26 01:25:11


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<unsigned long int, unsigned long int, double,
>>unsigned long int> 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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net