Boost logo

Boost :

From: Brian McNamara (lorgon_at_[hidden])
Date: 2003-10-26 21:58:08


On Sun, Oct 26, 2003 at 08:52:32PM -0500, David Abrahams wrote:
> I'd like to make a small plea to consider usefulness over technical
> accuracy. I find myself consciously avoiding is_base_and_derived ever
> since we decided it should return false the case where the two types
> are actually the same. This is partly because I nearly always want to
> treat the case where the two types are the same in the same way as
> when they are actually base and derived classes (or else it's a case
> where I don't care about the outcome of that case), and partly because
> I know it costs extra compile time resources to rule that case out. I
> know I can get the effect I want with
>
> is_convertible<D*,B*>
>
> but it's far less clear than writing is_base_and_derived<B,D>. I
> honestly can't imagine a case where I'd want the semantics as they're
> currently defined. I think we should either change the semantics back
> (possibly changing the name to something more appropriate if people
> are more comfortable with that) or simply remove is_base_and_derived,
> unless someone can come up with a compelling case for keeping it.

How about

   is_proper_supertype< B, D > // like current is_base_and_derived
   is_supertype< B, D > // as above, but also true if B==D

IMO those names cleanly capture the relevent abstractions, and
is_supertype (which you're arguing is the commoner case, and I agree)
can be implemented more efficiently than is_base_and_derived.

Actually I'd prefer

   is_proper_subtype< D, B >
   is_subtype< D, B >

but you have to be careful that you reverse the argument order when
changing your old code over from is_base_and_derived.

-- 
-Brian McNamara (lorgon_at_[hidden])

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