HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
traits.h File Reference
#include "pxr/pxr.h"
#include <map>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>
+ Include dependency graph for traits.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

template<typename T >
using VdfByValueOrConstRef = typename std::conditional_t< std::is_pointer_v< T >||Vdf_AndTypeIsSmall< T, std::is_arithmetic_v< T >>||Vdf_AndTypeIsSmall< T, std::is_enum_v< T >>, T, const T & >
 

Variables

template<typename , typename = void>
PXR_NAMESPACE_OPEN_SCOPE
constexpr bool 
Vdf_IsEqualityComparableHelper = false
 
template<typename T >
constexpr bool VdfIsEqualityComparable
 
template<typename , bool >
constexpr bool Vdf_AndTypeIsSmall = false
 
template<typename T >
constexpr bool Vdf_AndTypeIsSmall< T, true > = sizeof(T) <= sizeof(void*)
 

Typedef Documentation

template<typename T >
using VdfByValueOrConstRef = typename std::conditional_t< std::is_pointer_v<T> || Vdf_AndTypeIsSmall<T, std::is_arithmetic_v<T>> || Vdf_AndTypeIsSmall<T, std::is_enum_v<T>>, T, const T &>

Template that evaluates to either T or const T & depending on whether T best be passed as value or const reference.

The heuristic here is as follows:

  • T if T is a ptr, arithmetic type, or enum, and also <= size of a ptr
  • const T & in all other cases

Note that this heuristic is a best guess given a generic type T, but if the type is known the call site may be able to make a more informed decision on how to pass parameters and return values without the use of this facility.

Definition at line 108 of file traits.h.

Variable Documentation

template<typename , bool >
constexpr bool Vdf_AndTypeIsSmall = false

Definition at line 84 of file traits.h.

template<typename T >
constexpr bool Vdf_AndTypeIsSmall< T, true > = sizeof(T) <= sizeof(void*)

Definition at line 89 of file traits.h.

template<typename , typename = void>
PXR_NAMESPACE_OPEN_SCOPE constexpr bool Vdf_IsEqualityComparableHelper = false

Definition at line 27 of file traits.h.

template<typename T >
constexpr bool VdfIsEqualityComparable
Initial value:
=
Vdf_IsEqualityComparableHelper<T>

Variable template that returns true if equality comparison is a valid operation for type T.

For compound types, specializations must be provided along the lines of the following example:

```cpp // ContainerType<T> is equality comparable iff T is equality comparable. template <typename t>=""> constexpr bool VdfIsEqualityComparable<ContainerType<T>> = VdfIsEqualityComparable<T>; ```

Definition at line 49 of file traits.h.