Boost logo

Boost Users :

From: David Klein (dave_chp_at_[hidden])
Date: 2007-02-09 13:32:27


Meryl Silverburgh wrote:
> Hi,
>
> I have code like this which sort a Rect, which compare value of
> getY(), like this:
>
> vector<Rect*> rl;
>
> ::sort(rl.begin(), rl.end(), bind(less < int >(),
> bind(&Rect::getY, _1), bind(&Rect::getY, _2)));
>
> how can I change it so that it compares with the 'y' attribute? like,
> rect1.y < rect2.y?
>
> Thank you.
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>
Hi Meryl,

well, just replace &Rect::getY with &Rect::y :)

sort(
  rl.begin(),
  rl.end(),
  bind(
    less<int>(),
    bind(&Rect::y, _1),
    bind(&Rect::y, _2)
  )
);

--
HTH dave

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