Boost logo

Boost :

From: Scott McCaskill (scott_at_[hidden])
Date: 2001-08-17 08:59:46

> On Thursday, August 16, 2001, at 05:07 PM, Scott McCaskill wrote:
> > I'd like to propose a minor addition to smart_ptr.hpp: operator<() for
> > comparing two shared_ptrs. Without such an operator, it's not possible
> > use shared_ptr in certain STL containers (such as set) without defining
> > one's own predicate.
> shared_ptr already has a specialization of std::less that accomplishes
> this. Some have made a good argument for using an operator < rather than
> std::less, but others like the current implementation. (I'll dig up the
> relevant messages in the Boost archives if you want me too.)

Thanks, I'll look around in the archives.

> Given the current implementation, you should be able to use shared_ptr in
> a set. Have you tried it?

Yes, that's how I ran into this problem. I'm using MSVC 6, and it won't
compile the following:

std::set<boost::shared_ptr<int> > s;
s.insert( boost::shared_ptr<int>( new int ) );

Boost list run by bdawes at, gregod at, cpdaniel at, john at