Boost logo

Boost Users :

From: Darin Adler (darin_at_[hidden])
Date: 2002-08-29 14:13:17


On Thursday, August 29, 2002, at 11:07 AM, alejandro_escalante_medina
wrote:

> Hello to everyone. I'm starting to take a look on Boost and was happy
> to find things like better smart pointers. Though, in my tests, I
> haven't been able to sort, say, a vector of shared_ptr without
> defining special comparators. I thought that the overload for the <
> operator would help me for that, but that operator compares pointers,
> not objects, so it doesn't do the work that I expected.
>
> I guess I'm not understanding this well. Could someone explain this to
> me?

Almost any technique that works for sorting a container of pointers,
based on the values of the objects pointed to would also work for a
container of shared_ptr's. That's the design approach of shared_ptr; it
has the same semantics as pointers.

I found an article by Dietmar Kuehl at
http://www.oonumerics.org/tmpw00/kuehl.html which talks about this very
issue. You might find it helpful.

     -- Darin


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