Monado OpenXR Runtime
Loading...
Searching...
No Matches
g_traits.hpp
Go to the documentation of this file.
1
// Copyright 2026, NVIDIA CORPORATION.
2
// SPDX-License-Identifier: BSL-1.0
3
/*!
4
* @file
5
* @brief Shared type traits for glue classes.
6
* @ingroup aux_util
7
*/
8
9
#pragma once
10
11
#include <type_traits>
12
13
14
namespace
xrt::util {
15
16
/*!
17
* True when `Base` is an accessible, non-virtual base of `Derived`, that is a
18
* `Base *` can be `static_cast` down to `Derived *`. That cast is ill-formed
19
* for a virtual base, so this is false for virtual inheritance. The glue
20
* wrappers use it to reject virtual inheritance of the glue base, which would
21
* break pointer recovery.
22
*
23
* @todo C++17 has no direct trait for "is virtual base"; revisit with a
24
* cleaner formulation if reflection (C++26) makes one available.
25
*/
26
template
<
class
Base,
class
Derived,
class
=
void
>
inline
constexpr
bool
is_non_virtual_base_v
=
false
;
27
28
template
<
class
Base,
class
Derived>
29
inline
constexpr
bool
30
is_non_virtual_base_v<Base, Derived, std::void_t<decltype(static_cast<Derived *>(
static_cast<
Base *
>
(
nullptr
)))>> =
31
true
;
32
33
}
// namespace xrt::util
xrt::util::is_non_virtual_base_v
constexpr bool is_non_virtual_base_v
True when Base is an accessible, non-virtual base of Derived, that is a Base * can be static_cast dow...
Definition
g_traits.hpp:26
auxiliary
glue
g_traits.hpp
Generated by
1.9.8