|
C++ Cast Utilities. More...
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. | |
template<typename T > | |
std::enable_if<!std::is_polymorphic< T >::value, Tf_CopyCV< T, void > * >::type | TfCastToMostDerivedType (T *ptr) |
C++ Cast Utilities.
Definition in file cxxCast.h.
|
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.