Boost logo

Boost :

From: John Maddock (jm_at_[hidden])
Date: 2003-01-28 07:56:07


> >"Thomas Witt" <witt_at_[hidden]> wrote in message
> >news:3E3590ED.8030100_at_ive.uni-hannover.de...
> >> IIUC is_based_and_derived<T,T> evaluates to true as well. Is a class T
> >> strictly speaking a base class of itself?
> >
> >Yes
>
> That's a convention of is_base_and_derived though. To the standard a
> class is not a base of itself, so this convention should be
> documented. In other words, you have to specify whether the ordering
> is strict or not.

Yes, a class is it's own superclass/subclass, but IMO not it's own base: so
it is a bug in the implementation.

> Incidentally, I've noticed that boost's implementation of
> is_base_and_derived has the same access-checking problems as
> is_convertible. That could be easily fixed, as said in the thread
> about is convertible, by using function templates:
>
>
> typedef char (&no_type)[1];
> typedef char (&yes_type)[2];
>
> template <typename T>
> struct identity { typedef T type; };
>
> template <typename To>
> no_type is_convertible(...);
>
> template <typename To>
> yes_type is_convertible(typename identity<To>::type);

IMO your identity template only serves to trip up less capable compilers, it
does nothing to solve member access problems.

John Maddock
http://ourworld.compuserve.com/homepages/john_maddock/index.htm


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