HasBase< D, B > Struct Template Reference 系统

#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).

Public Types

using  DT = typename std::decay< D >::type
using  BT = typename std::decay< B >::type
using  Helper = maxon::details::HasBaseHelper < DT , BT , maxon::details::CheckHasBaseHelper < DT , BT >:: value >

静态公共成员函数

static BT Cast ( DT *ptr)
static const BT Cast (const DT *ptr)

静态公共属性

static const Bool   value

Member Typedef Documentation

◆  DT

using DT = typename std::decay<D>::type

◆  BT

using BT = typename std::decay<B>::type

◆  Helper

using Helper = maxon::details::HasBaseHelper < DT , BT , maxon::details::CheckHasBaseHelper < DT , BT >:: value >

成员函数文档编制

◆  Cast() [1/2]

static BT * Cast ( DT ptr )
static

◆  Cast() [2/2]

static const BT * Cast ( const DT ptr )
static

Member Data Documentation

◆  value

const Bool value static