"Peter Dimov" <[EMAIL PROTECTED]> wrote in message
007001c2c78e$ca921550$1d00a8c0@pdimov2">news:007001c2c78e$ca921550$1d00a8c0@pdimov2...
> From: "Rani Sharoni" <[EMAIL PROTECTED]>
> >
> > I fogot to show little usability sample:
> >
> > struct B {};
> > struct B1 : B {};
> > struct B2 : B {};
> > struct D : B1, private B2 {};
> >
> > typedef char Test[is_base_and_derived<B, D>::result]; // improvement 1 -
> > multiple base
> > typedef char Test[is_base_and_derived<B1,D>::result];
> > typedef char Test[is_base_and_derived<B2,D>::result]; // improvement 2 -
> > private base
> > typedef char Test[!is_base_and_derived<int,D>::result];
>
> Very clever. But I'm not sure whether this is what is_base_and_derived is
> supposed to check. It seems that many are using it as
> is_accessible_base_of_derived, is-a, or is_convertible<D*, B*>.

IMHO there is only positive improvement.



Private base:

The current implementation will cause compile time error in all cases.

The new implementation will be good when there is access in the context of
the usage:

template<typename T>

void f(T *) { /* use is_base_and_derived<B, T>::result to convert T to B
*/ }

class A : B { friend void f<>(A*); }



It can also be abused to get access using c-cast:

if_< is_base_and_derived<B, A>::result, /* (B*)aptr */ , /* ??? */ >



Multiple bases:

For the ambiguity improvement I’ll just mention that Eric Niebler asked for
the is_com_ptr trait and I wanted to help him.



Rani





_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to