Background:
In C++, the following dynamic cast is not valid:
const BaseClass* base = ...; const SubClass* sub = dynamic_cast<const SubClass*>( base );
Such a cast is needed at many places. So, this class makes such a cast possible.
Typical Usage:
const FromClass* base = ...; const ToClass* sub = ConstDynamicCast<FromClass>(base).get<ToClass>();
Public Member Functions | |
ConstDynamicCast (const FromClass *from_ptr) | |
Create an object ready for dynamic casting with get(). | |
template<class ToClass> | |
const ToClass * | get () const |
Dynamic cast to the class ToClass. |
code::ConstDynamicCast< FromClass >::ConstDynamicCast | ( | const FromClass * | from_ptr | ) | [inline] |
Create an object ready for dynamic casting with get().
const ToClass* code::ConstDynamicCast< FromClass >::get | ( | ) | const [inline] |
Dynamic cast to the class ToClass.