|
Boost : |
From: Valentin Bonnard (Bonnard.V_at_[hidden])
Date: 1999-09-02 10:32:22
Beman Dawes wrote:
>
> Kevlin Henney wrote:
> > template<class Derived, class Base>
> > inline Derived safe_downcast(Base* x)
> > {
> > assert(dynamic_cast<Derived>(x) != 0);
> > if(false)
> > dynamic_cast<Derived>(x);
> > return static_cast<Derived>(x);
> > }
> Kevlin, after wading throught the standard's description of
> dynamic_cast twice, I am still having trouble knowing which errors
> your added code will detect, and which will still get through. Could
> you enlighten me?
dynamic_cast from a base class w/ no virtual functions
to a derived class is ill-formed, but static_cast in
such case is well-formed.
That's the only difference in static semantic I can
think of for the moment.
-- Valentin Bonnard
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk