Boost logo

Boost :

From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2006-07-13 17:06:42


Sean Parent wrote:

> For pair<shared_ptr<>, int> - what makes shared_ptr special? This
> doesn't work pair<T*, int> today - I don't see why we should special
> case shared_ptr - especially in a way which should likely change in
> the future. Rather I'd recommend specializing std::less - note that
> you could also specialize std::less<> for std::pair<shared_ptr<>, T>
> (and the two other variants) if this is _really_ a big concern. I
> haven't run across a need to order pairs with shared_ptr (nor a pair
> with pointers for that matter).

I think I have a basic understanding of your logic, but let's think about
practicality for a moment. I'm not saying logical and philosophical reasons
are not appropriate for this discussion, but let's try and not think about
them for a second.

The ordering defined by the operator< overload for shared_ptr has the
following important property: it is independent of shared_ptr's template
parameter. You can order shared_ptr<void> objects, if you like. Or, a
shared_ptr<void> and a shared_ptr<int>.

Can you think of any problems that operator< could cause, in its current
definition? In my mind, since you can't use T in your ordering semantics,
you have no reasons to define your own ordering for shared_ptr. Therefore,
you have no other use for operator<, and therefore if the one defined by the
library causes no problems, we should keep it because it is practical.

--Emil


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