XRTraits C++ OpenXR Utilities
|
Casts for OpenXR tagged types, as well as utilities for traversing a next
chain.
More...
Functions | |
template<typename TargetType , typename SourceType > | |
TargetType | xr_get_chained_struct (SourceType *src) |
template<typename T > | |
T * | xr_get_chained_struct (T *src) |
template<typename TargetType , typename SourceType > | |
TargetType | xr_tagged_dynamic_cast (SourceType &&source) |
template<typename TargetType , typename SourceType > | |
TargetType | xr_tagged_risky_cast (SourceType source) |
Casts for OpenXR tagged types, as well as utilities for traversing a next
chain.
The non-chained "cast-like" functions:
In both xr_tagged_dynamic_cast() and xr_tagged_risky_cast(), if the target type parameter you supply is a pointer type, a null pointer input or mismatch of the type
member with your target type will result in the cast returning nullptr
if your target is a pointer type, or throwing xrtraits::exceptions::bad_tagged_cast if your target is a reference type. Choose whether to request a pointer or reference type as target based on your confidence that the input is the right type; remember that exceptions are for exceptional cases. This behavior intentionally resembles the standard dynamic_cast.
void *
or const void *
, but you can confidently say that the pointed object is an OpenXR tagged type. (It relies on this assumption!) Does not take references as input parameters - references to void make little sense.If these are used wrong, there are static assertions that will try to provide a helpful error message.