XRTraits C++ OpenXR Utilities
Classes | Functions | Variables
xrtraits::traits Namespace Reference

C++11/14/17 "type traits" for manipulating and reasoning about types at compile-time. More...

Classes

struct  TypeWrapper
 

Functions

constexpr const char * to_string (XrStructureType t)
 
constexpr const char * getTypeName (XrStructureType t)
 
template<typename F >
constexpr void typeDispatch (XrStructureType t, F &&f)
 

Variables

template<typename T >
constexpr bool is_xr_tagged_type_v
 
template<typename T >
constexpr bool has_xr_type_tag_v
 
template<typename T >
constexpr XrStructureType xr_type_tag_v
 
template<typename T >
constexpr bool has_const_next_pointer_v
 
template<typename SourceType , typename TargetType >
constexpr bool same_constness
 Do SourceType and TargetType have the same const-qualifications? More...
 

Detailed Description

C++11/14/17 "type traits" for manipulating and reasoning about types at compile-time.

Also includes a few other constexpr (compile time or run time) functions based on generated code.

Function Documentation

◆ getTypeName()

constexpr const char* xrtraits::traits::getTypeName ( XrStructureType  t)

Get the type name string associated with a type enum value, or nullptr if not recognized.

◆ to_string()

constexpr const char* xrtraits::traits::to_string ( XrStructureType  t)

Get a string corresponding to a type enum value, or nullptr if not recognized.

◆ typeDispatch()

template<typename F >
constexpr void xrtraits::traits::typeDispatch ( XrStructureType  t,
F &&  f 
)

Calls your functor with a TypeWrapper<T> argument, where T is the static type matching the enum value.

If the enum value is not recognized, your functor will not be called.

Variable Documentation

◆ has_const_next_pointer_v

template<typename T >
constexpr bool xrtraits::traits::has_const_next_pointer_v
Initial value:
=
detail::remove_reference_pointer_cv_t<T>>
constexpr bool has_const_next_pointer_v
Definition: APITraits.h:134

Identify if a tagged type has a const next pointer.

Removes pointer, reference, and const from type before looking it up.

◆ has_xr_type_tag_v

template<typename T >
constexpr bool xrtraits::traits::has_xr_type_tag_v
Initial value:
= detail::has_xr_type_tag_impl_v<
detail::remove_reference_pointer_cv_t<T>>

For types that are XR tagged types and have a defined enum value (type tag) for their type member, this is true.

Note: Not all types with is_xr_tagged_type_v have their own type tag: some (that primarily serve as "abstract" types) do not but are intended primarily as ways to pass references to concrete types that do have a defined type tag.

Removes pointer, reference, and const from type before looking it up.

◆ is_xr_tagged_type_v

template<typename T >
constexpr bool xrtraits::traits::is_xr_tagged_type_v
Initial value:
= detail::is_xr_tagged_type_impl_v<
detail::remove_reference_pointer_cv_t<T>>

true if the given type is an XR tagged type (starting with XrStructureType type; const void* next;).

Note that this does not imply that there is a (known) XrStructureType enum value (for use in the type member) that corresponds to T. For that,

See also
has_xr_type_tag_v

Removes pointer, reference, and const from type before looking it up.

◆ same_constness

template<typename SourceType , typename TargetType >
constexpr bool xrtraits::traits::same_constness
Initial value:
= (is_const_v<SourceType> ==
is_const_v<TargetType>)

Do SourceType and TargetType have the same const-qualifications?

◆ xr_type_tag_v

template<typename T >
constexpr XrStructureType xrtraits::traits::xr_type_tag_v
Initial value:
= detail::xr_type_tag_impl_v<
detail::remove_reference_pointer_cv_t<T>>

Access the defined enum value (type tag) for the type member of an XR tagged type with known tag.

Removes pointer, reference, and const from type before looking it up.