std::meta::is_virtual_base_of_type
| Defined in header <meta>
|
||
consteval bool
is_virtual_base_of_type( std::meta::info base, std::meta::info derived );
|
(since C++26) | |
Let Base and Derived be classes represented by base and derived, respectively.
If Base is a virtual base class of Derived (ignoring cv-qualification), returns true. Otherwise, returns false.
If both Base and Derived are non-union class types (ignoring cv-qualification), Derived must be a complete type; otherwise the program is ill-formed.
Parameters
| base, derived | - | reflection values |
Return value
true if Derived is derived from virtual base class Base (ignoring cv-qualification); otherwise false.
Exceptions
Throws std::meta::exception if either base or derived does not represent a type or type alias.
Notes
is_virtual_base_of_type(^^A, ^^B) is true even if A is a private, protected, or ambiguous base class of B.
If is_virtual_base_of_type(^^A, ^^B) is true, then std::meta::is_base_of_type(^^A, ^^B) is also true. However, the converse is not always true because the check for virtual inheritance is more specific. In that case, is_virtual_base_of_type(^^T, ^^T) is false even if T is a non-union class type.
Example
#include <meta>
class A {};
class B : A {};
class C : B {};
class D : virtual A {};
class E : D {};
union F {};
using I = int;
static_assert
(
is_virtual_base_of_type(^^A, ^^A) != true &&
is_virtual_base_of_type(^^A, ^^B) != true &&
is_virtual_base_of_type(^^A, ^^D) == true &&
is_virtual_base_of_type(^^D, ^^E) != true &&
is_virtual_base_of_type(^^F, ^^F) != true &&
is_virtual_base_of_type(^^I, ^^I) != true &&
"");
int main() {}
