code::ConstDynamicCast< FromClass > Class Template Reference

List of all members.

Detailed Description

template<class FromClass>
class code::ConstDynamicCast< FromClass >

Will dynamic cast one const* pointer into another const* pointer.

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>();
     
Author:
Lakshman
Version:
Id
code_ConstDynamicCast.h,v 1.3 2009/06/02 20:17:39 lakshman Exp


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.


Constructor & Destructor Documentation

template<class FromClass>
code::ConstDynamicCast< FromClass >::ConstDynamicCast ( const FromClass *  from_ptr  )  [inline]

Create an object ready for dynamic casting with get().


Member Function Documentation

template<class FromClass>
template<class ToClass>
const ToClass* code::ConstDynamicCast< FromClass >::get (  )  const [inline]

Dynamic cast to the class ToClass.

Returns:
0 on error and a valid ToClass pointer on success.


Generated on Fri May 4 13:40:12 2012 for WDSS-IIw2 by  doxygen 1.4.7