Boost logo

Boost :

From: Valentin Bonnard (Bonnard.V_at_[hidden])
Date: 1999-11-10 13:02:52

ivan66_at_[hidden] wrote:

> 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>,

It depends on the declaration of op== (member or non member).

1) member: conversions allowed on rhs but not lhs
   => base == derived passes
   but derived == base fails
   => very strange dissymmetric effect

2) non member: no conversions at all
   => symmetry in that base == derived and derived == base
      both fail the same way

> but attempting comparison with a
> shared_array<Derived> would trigger a compile-time error?

Definitely (there are no conversions between shared_array<>s).

Valentin Bonnard

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