|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2000-05-30 15:32:54
> BTW, in my experience the hack someone suggested a while back to get
> these things to work with MSVC6 doesn't work:
>
> template <typename Base, typename Derived>
> Base * upcast(Derived * const d, Base* = 0)
> { return static_cast<Derived *>(static_cast<Base *>(d)); }
What exactly doesn't work? This compiles:
template <typename Base, typename Derived>
Base * upcast(Derived * const d, Base * = 0)
{
return static_cast<Derived *>(static_cast<Base *>(d));
}
struct base {};
struct derived: base {};
int main()
{
derived d;
base * pb = upcast<base>(&d);
return 0;
}
-- Peter Dimov Multi Media Ltd.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk