Loading...
Searching...
No Matches
traits.h File Reference
+ 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 & >
 Template that evaluates to either T or const T & depending on whether T best be passed as value or const reference.
 

Variables

template<typename , typename = void>
constexpr bool Vdf_IsEqualityComparableHelper = false
 
template<typename T >
constexpr bool VdfIsEqualityComparable
 Variable template that returns true if equality comparison is a valid operation for type T.
 
template<typename , bool >
constexpr bool Vdf_AndTypeIsSmall = false
 
template<typename T >
constexpr bool Vdf_AndTypeIsSmall< T, true > = sizeof(T) <= sizeof(void*)
 

Typedef Documentation

◆ VdfByValueOrConstRef

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 104 of file traits.h.

Variable Documentation

◆ Vdf_AndTypeIsSmall

constexpr bool Vdf_AndTypeIsSmall = false
constexpr

Definition at line 84 of file traits.h.

◆ Vdf_AndTypeIsSmall< T, true >

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

Definition at line 89 of file traits.h.

◆ Vdf_IsEqualityComparableHelper

constexpr bool Vdf_IsEqualityComparableHelper = false
constexpr

Definition at line 27 of file traits.h.

◆ VdfIsEqualityComparable

constexpr bool VdfIsEqualityComparable
constexpr
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:

// 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.