7#ifndef PXR_EXEC_VDF_TRAITS_H
8#define PXR_EXEC_VDF_TRAITS_H
16#include <unordered_map>
20PXR_NAMESPACE_OPEN_SCOPE
26template <
typename,
typename =
void>
27constexpr bool Vdf_IsEqualityComparableHelper =
false;
31constexpr bool Vdf_IsEqualityComparableHelper<
32 T, std::void_t<decltype(std::declval<T>() == std::declval<T>())>> =
true;
50 Vdf_IsEqualityComparableHelper<T>;
53template <
class T,
class Allocator>
54constexpr bool VdfIsEqualityComparable<std::vector<T, Allocator>> =
55 VdfIsEqualityComparable<T>;
59template <
class T1,
class T2>
60constexpr bool VdfIsEqualityComparable<std::pair<T1, T2>> =
61 VdfIsEqualityComparable<T1> && VdfIsEqualityComparable<T2>;
65template <
class Key,
class T,
class Compare,
class Allocator>
67 std::map<Key, T, Compare, Allocator>> =
68 VdfIsEqualityComparable<Key> && VdfIsEqualityComparable<T>;
72template <
class Key,
class T,
class Hash,
class KeyEqual,
class Allocator>
74 std::unordered_map<Key, T, Hash, KeyEqual, Allocator>> =
75 VdfIsEqualityComparable<Key> && VdfIsEqualityComparable<T>;
83template <
typename,
bool>
84constexpr bool Vdf_AndTypeIsSmall =
false;
89constexpr bool Vdf_AndTypeIsSmall<T, true> =
sizeof(T) <=
sizeof(
void*);
105 std::is_pointer_v<T> ||
106 Vdf_AndTypeIsSmall<T, std::is_arithmetic_v<T>> ||
107 Vdf_AndTypeIsSmall<T, std::is_enum_v<T>>,
110PXR_NAMESPACE_CLOSE_SCOPE
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 & > VdfByValueOrConstRef
Template that evaluates to either T or const T & depending on whether T best be passed as value or co...
constexpr bool VdfIsEqualityComparable
Variable template that returns true if equality comparison is a valid operation for type T.