| Type traits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compile-time rational arithmetic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compile-time integer sequences | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(C++14) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Defined in header <type_traits> | ||
template<class Base,class Derived> struct is_virtual_base_of; | (since C++26) | |
std::is_virtual_base_of is aBinaryTypeTrait.
IfBase is avirtual base class ofDerived (ignoring cv-qualification), provides the member constantvalue equal totrue. Otherwisevalue isfalse.
If bothBase andDerived are non-union class types (ignoring cv-qualification),Derived should be acomplete type; otherwise the behavior is undefined.
If the program adds specializations forstd::is_virtual_base_of orstd::is_virtual_base_of_v, the behavior is undefined.
Contents |
template<class Base,class Derived> constexprbool is_virtual_base_of_v= is_virtual_base_of<Base, Derived>::value; | (since C++26) | |
value [static] | true ifDerived is derived from virtual base classBase (ignoring cv-qualification),false otherwise(public static member constant) |
operator bool | converts the object tobool, returnsvalue (public member function) |
operator() (C++14) | returnsvalue (public member function) |
| Type | Definition |
value_type | bool |
type | std::integral_constant<bool, value> |
std::is_virtual_base_of_v<A, B> istrue even ifA is a private, protected, or ambiguous base class ofB.
Ifstd::is_virtual_base_of_v<A, B> istrue, thenstd::is_base_of_v<A, B> is alsotrue. However, the converse is not always true because the check for virtual inheritance is more specific. In that case,std::is_virtual_base_of_v<T, T> isfalse even ifT is a non-union class type.
#include <type_traits> class A{};class B: A{};class C: B{};class D:virtual A{};class E: D{}; union F{};using I=int; static_assert( std::is_virtual_base_of_v<A, A>!=true&& std::is_virtual_base_of_v<A, B>!=true&& std::is_virtual_base_of_v<A, D>==true&& std::is_virtual_base_of_v<D, E>!=true&& std::is_virtual_base_of_v<F, F>!=true&& std::is_virtual_base_of_v<I, I>!=true); int main(){}
(C++11) | checks if a type is a base of the other type (class template)[edit] |
(C++11)(C++20) | checks if a type can be converted to the other type (class template)[edit] |
(C++20) | specifies that a type is derived from another type (concept)[edit] |