Boost logo

Boost :

Subject: Re: [boost] Downcast taking account of virtual inheritance
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2010-02-14 17:47:56


----- Original Message -----
From: "Robert Ramey" <ramey_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Sunday, February 14, 2010 11:28 PM
Subject: Re: [boost] Downcast taking account of virtual inheritance

>
> Kim Barrett wrote:
 
>> I think the correct fix is to leave the existing derivation test in
>> place, but augment it with the is_virtual_base_of test, i.e. mpl::or_
>> the existing test for cross-cast (T and U have no base/derived
>> relationship) with the is_virtual_base_of test.
>
> That would sound correct to me.

I have teste this and this should complete conveniently the smart_cast function.

                    typedef
                        BOOST_DEDUCED_TYPENAME mpl::eval_if<
                            BOOST_DEDUCED_TYPENAME mpl::or_<
                                is_virtual_base_of<U, BOOST_DEDUCED_TYPENAME remove_pointer<T>::type,
                                BOOST_DEDUCED_TYPENAME mpl::and_<
                                    mpl::not_<is_base_and_derived<
                                        BOOST_DEDUCED_TYPENAME remove_pointer<T>::type,
                                        U
> >,
                                    mpl::not_<is_base_and_derived<
                                        U,
                                        BOOST_DEDUCED_TYPENAME remove_pointer<T>::type
> >
>
>,
                            // borland chokes w/o full qualification here
                            mpl::identity<cross>,
                            mpl::identity<linear>
>::type typex;
                    return typex::cast(u);

Robert, could you add this enhancement for the next release.

Thanks,
Vicente


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