Boost logo

Boost Users :

Subject: [Boost-users] ptr_vector sort usage
From: archie14 (admin_at_[hidden])
Date: 2010-08-04 23:12:42

I can't figure out how to use "sort" method in ptr_vector with the function
object. Operator < should be defined, but for various reasons I cant define it
in the class A, and I have to do the comparison between the A values using
some other values.


class A
    int i;

class Compare
    Compare (int i) : _i(i){}
    //this does not compile, but what's the proper way to define
    // function object for the sort method in ptr_vector?
    bool operator<(const A& v1, const A& v2)
       return (v1.i > v2.i) &&(_i != 1);
   int _i;

ptr_vector<A> lst;
Compare cmp(3);

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at