Boost logo

Boost :

From: ivan66_at_[hidden]
Date: 1999-11-09 21:09:56

darin adler <dari-_at_[hidden]> wrote:
original article:
> > Well, what would you want it to do, compare the pointers
> > or the contained objects? That's a good enough reason as
> > far as I'm concerned.
> Hmm. I had assumed that given this
> shared_ptr<X> a;
> shared_ptr<X> b;
> that this
> a == b
> would compare the pointers and this
> *a == *b
> would compare the objects.
> It seems a bit extreme to leave this up to each individual programmer
> decide. But I'd like to hear others' thoughts on the matter.
> -- Darin

That sounds reasonable. shared_ptr has pointer-like semantics, so its
operator== should have pointer-like semantics too. If for some reason
you did want to compare objects and not pointers, the '*a == *b' syntax
is clean and already supported.

I assume that it would be legal to compare a shared_ptr<Derived> with a
shared_ptr<Base>? Also, that a shared_array<Base> could be compared to
a shared_array<Base>, but attempting comparison with a
shared_array<Derived> would trigger a compile-time error?

Best regards,
Ivan J. Johnson

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