HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxxCast.h File Reference
#include "pxr/pxr.h"
#include <type_traits>
+ 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.

Typedefs

template<class Src , class Dst >
using Tf_CopyConst = typename std::conditional< std::is_const< Src >::value, typename std::add_const< Dst >::type, Dst >::type
 
template<class Src , class Dst >
using Tf_CopyVolatile = typename std::conditional< std::is_volatile< Src >::value, typename std::add_volatile< Dst >::type, Dst >::type
 
template<class Src , class Dst >
using Tf_CopyCV = Tf_CopyConst< Src, Tf_CopyVolatile< Src, Dst >>
 

Functions

template<typename T >
std::enable_if
< std::is_polymorphic< T >
::value, Tf_CopyCV< T, void >
* >::type 
TfCastToMostDerivedType (T *ptr)
 
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.

Typedef Documentation

template<class Src , class Dst >
using Tf_CopyConst = typename std::conditional<std::is_const<Src>::value, typename std::add_const<Dst>::type, Dst>::type

Definition at line 42 of file cxxCast.h.

template<class Src , class Dst >
using Tf_CopyCV = Tf_CopyConst<Src, Tf_CopyVolatile<Src, Dst>>

Definition at line 50 of file cxxCast.h.

template<class Src , class Dst >
using Tf_CopyVolatile = typename std::conditional<std::is_volatile<Src>::value, typename std::add_volatile<Dst>::type, Dst>::type

Definition at line 47 of file cxxCast.h.

Function Documentation

template<typename T >
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.

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

Definition at line 75 of file cxxCast.h.