#include <apibase.h>
详细描述
template<typename D, typename B>
struct maxon::HasBase< D, B >
This type trait checks if
D
has
B
as its base. This is the case if both are the same, or if both are virtual interfaces and
D
is (directly or indirecty) derived from
B
, or if
D
is derived from
B
as a C++ class.
若
D
has
B
as its base, the function
HasBase<D, B>Cast
can be used to cast a pointer of the derived type to a pointer of the base type. This has to be used instead of a reinterpret_cast because the latter doesn't handle correctly cases with virtual classes or multiple inheritance when there are offsets between derived and base pointers.
Internally, if
D
has a member type
HasBase
, the check is forwarded to
D::HasBase::Check<B>
which implements the case for virtual interfaces. Otherwise, the check is simply forwarded to
std::is_base_of<B, D>
.
-
Template Parameters
-
D
|
Derived type to check (potential reference and const qualifiers are removed).
|
B
|
Base type to check (potential reference and const qualifiers are removed).
|