Boost logo

Boost :

From: williamkempf_at_[hidden]
Date: 2001-05-24 09:54:48


--- In boost_at_y..., "Peter Dimov" <pdimov_at_m...> wrote:
> I have some comments on shared_ptr.
>
> 1. Isn't specializing std::less without defining the corresponding
operator<
> setting a dangerous precedent? This means that sort(f, l) and sort
(f, l,
> less<>()) could potentially give different results.

Sometimes it's valid to have less<type> but not operator<(type,
type). Not that this is such a case, but it makes it less likely
that a "dangerous precedent" is being set.

Since the standard defines full relational operations for pointer
types, however, I'd agree that shared_ptr could benefit from them.
Given that std::auto_ptr doesn't provide them, however, is something
to at least note.
 
> 2. I need to access shared_ptr::pn. Really.
>
> Consider this case:
>
> shared_ptr<A> pa;
> shared_ptr<B> pb;
>
> Do pa and pb point to the same object? No way to tell without
comparing
> pa.pn and pb.pn.

I don't get this. Take shared_ptr<> out of the equation and you get
this:

A* pa;
B* pb;

Do pa and pb point to the same object now? If you can figure this
out then you can figure it out for shared_ptr<> by using get(), and
if you can't than shared_ptr<> shouldn't allow you to figure it out
either.

Regardless, access to pn would be a mistake.

Bill Kempf


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk