|
Boost : |
From: Joel de Guzman (joel_at_[hidden])
Date: 2003-10-26 23:11:52
Brian McNamara <lorgon_at_[hidden]> wrote:
> 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.
Man! You beat me to the punch. I was going to suggest that ;-)
Well, actually, to avoid confusing real subtypes from subclasses
(in C++, both are the same), I'd suggest:
is_proper_subclass< D, B >
is_subclass< D, B >
Regards,
-- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk