Boost logo

Boost :

From: Greg Colvin (gcolvin_at_[hidden])
Date: 2000-10-31 04:14:37


From: Csaba Szepesvari <szepes_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Tuesday, October 31, 2000 1:51 AM
Subject: Re: [boost] dynamic_cast in MSland

> > The following ugly patch seems to fix the problem:
> >
> > template<class T,class U> T do_dynamic_cast(U& r) {
> > return dynamic_cast<T>(r);
> > }
> > template<class T,class U> T do_dynamic_cast(U* p) {
> > return dynamic_cast<T>(p);
> > }
> > #define dynamic_cast do_dynamic_cast
> >
>
> Note: Strictly speaking, you do not need to use the macro in the second
> case (bad pointer-casts do not throw but return 0).
> In other words, if you used dynamic_cast only with pointers with MSVC -
> you're safe.

Small consolation.

> (But of course if you want a uniform substitute then you need both
> macros)

Yes, we need a uniform substitute. Of course the macro is ugly,
and strictly speaking a violation of the C++ standard. But then
again, MSVC is not a C++ compiler.


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