Boost logo

Boost Users :

From: Scott McMurray (me22.ca+boost_at_[hidden])
Date: 2007-07-23 09:49:52


On 23/07/07, bringiton bringiton <kneeride_at_[hidden]> wrote:
> OK this doesn't sort by integer. I was hoping shared_ptrs < operator
> actually used the < operator of it's template type. however, i guess
> it's sorting by pointer value...

A shared_ptr is still a pointer, so the principle of least surprise
means that it should sort like a pointer.

> Does anyone have a better way of doing this? Maybe boost already
> defines a function similar to my X function. Maybe there is a way
> without using a predicate...

This is one of my all-time favourite Boost.Lambda examples:
std::sort( v.begin(), v.end(), *_1 < *_2 );

~ Scott


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