BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslmf_isaccessiblebaseof

Detailed Description

Outline

Purpose

Provide a compile-time check for derived classes.

Classes

Description

This component provides a meta-function, bslmf::IsAccessibleBaseOf, that determines whether one class is an accessible base class of another class. The static constant bslmf::IsAccessibleBaseOf::value is true if the template parameter t_BASE class is an accessible base class of, or the same class as, the template parameter t_DERIVED. Otherwise, bslmf::IsAccessibleBaseOf::value is false. The specific cases of private, protected, and ambiguous inheritance are not supported for versions of C++ prior to 11.

Usage

In this section we show intended use of this component.

Example 1: Base And Derived Classes

Define two classes, one inheriting from the other.

struct Base
{};
struct Derived : Base
{};

Evaluate bslmf::IsAccessibleBaseOf::value.

Example 2: Unrelated Classes

Define two classes, one inheriting privately from the other.

class Unrelated
{};
class Unrelated2
{};

Evaluate bslmf::IsAccessibleBaseOf::value. Note that Derived is not observably derived from Base, so std::is_base_of would evaluate true, but bslmf::IsAccessibleBaseOf evaluates false.

void example2()
{
assert((false ==
}