[cxx-abi-dev] trivial __dynamic_cast fails?

David Abrahams dave at boost-consulting.com
Sat Feb 28 00:20:09 UTC 2004


David Baraff <deb at pixar.com> writes:


>> From: Daveed Vandevoorde <daveed at edg.com>
>
> Please note that Mark Mitchell already pointed me in the right
> direction, though it shifts a lot of implementation burden to me.  I
> can use the base_type_info to compute the address shift as I chain
> upward from derived to base, which is all I'm really after in this
> case.

Could you please outline the details?

>> There has been occasional talk among WG21/
>> J16 actives about adding a facility like
>> what David B. is looking for, but so far
>> no concrete proposals.  I'm going to CC
>> David Abrahams who mentioned the desire
>> for this once.  Perhaps he has some insight
>> into how widespread the need for this is.
>
> Here's a biggy.  Consider the boost::any class.  Currently, if it
> holds a Derived* and you ask it for a Base*, I think it says "no can
> do."  Imagine if it could actually say "yes, I can give you back a
> Base*", because it could dynamically look up the parent chain, and do
> the address shift.
>
> That would make boost::any a heck of a lot more useful than it is today.

boost::any could already be modified to do this, since it "knows" the
"Derived" type.  I've enclosed an implementation.  Seems to reveal EH
bugs in quite a few compilers, tho ;-)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: any.hpp
Type: text/x-cplusplus
Size: 4561 bytes
Desc: not available
URL: <http://sourcerytools.com/pipermail/cxx-abi-dev/attachments/20040227/5ae04187/attachment.bin>
-------------- next part --------------


-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com


More information about the cxx-abi-dev mailing list