All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxxCast.h File Reference

C++ Cast Utilities. More...

+ Include dependency graph for cxxCast.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename T >
std::enable_if
< std::is_polymorphic< T >
::value, Tf_CopyCV< T, void >
* >::type 
TfCastToMostDerivedType (T *ptr)
 Return a pointer to the most-derived object. More...
 
template<typename T >
std::enable_if
< !std::is_polymorphic< T >
::value, Tf_CopyCV< T, void >
* >::type 
TfCastToMostDerivedType (T *ptr)
 

Detailed Description

C++ Cast Utilities.

Definition in file cxxCast.h.

Function Documentation

std::enable_if< std::is_polymorphic<T>::value, Tf_CopyCV<T, void>*>::type TfCastToMostDerivedType ( T *  ptr)
inline

Return a pointer to the most-derived object.

A dynamic_cast to void* is legal only for pointers to polymorphic objects. This function returns the original pointer for non-polymorphic types, and a pointer to the most-derived type of the object. Said differently, given a pointer of static type B*, and given that the object really points to an object of type D*, this function returns the address of the object considered as a D*; however, for non-polymorphic objects, the actual type of an object is taken to be B, since one cannot prove that that the type is actually different.

Warning
This function is public, but should be used sparingly (or not all).

Definition at line 67 of file cxxCast.h.