Boost logo

Boost :

From: Darin Adler (darin_at_[hidden])
Date: 2002-04-24 16:13:43


On Wednesday, April 24, 2002, at 01:26 PM, Fernando Cacciola wrote:

> The conversion from Derived* to Base* might require a pointer fixup.
> This
> requires RTTI. C++ doesn't force the use of RTTI unless dynamic_cast<>
> is
> used, so the implicit conversion could go wrong in exactly the same
> way a
> C-style cast could go wrong if the conversion requires pointer value
> adjustment.
>
> IOWs, the template constructor acts exactly like a C-style cast between
> arbitrary pointers. If dynamic_cast<> isn't required in this situation,
> then
> when is it?

Conversion from Derived* to Base* might require a pointer fixup, but it
*never* requires RTTI.

The purpose of polymorphic_cast is to help for conversions from Base* to
Derived*. These types of conversions are never done automatically. They
always require some kind of cast.

This is not a problem with Peter's proposal.

     -- Darin


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