DART 6.13.2
|
A CRTP base class that provides an interface for easily casting to the derived types. More...
#include <Castable.hpp>
Public Member Functions | |
template<typename Derived > | |
bool | is () const |
Returns true if the types of this Base and the template parameter (a base class) are identical. | |
template<typename Derived > | |
const Derived * | as () const |
Casts to pointer of Derived if Base is its base class. | |
template<typename Derived > | |
Derived * | as () |
Casts to pointer of Derived if Base is its base class. | |
template<typename Derived > | |
const Derived & | asRef () const |
Casts to reference of Derived if Base is its base class. UB otherwise. | |
template<typename Derived > | |
Derived & | asRef () |
Casts to reference of Derived if Base is its base class. UB otherwise. | |
Private Member Functions | |
const Base & | base () const |
Casts to Base const-reference. | |
Base & | base () |
Casts to Base reference. | |
A CRTP base class that provides an interface for easily casting to the derived types.
Derived * dart::common::Castable< Base >::as | ( | ) |
Casts to pointer of Derived if Base is its base class.
Returns nullptr otherwise.
const Derived * dart::common::Castable< Base >::as | ( | ) | const |
Casts to pointer of Derived if Base is its base class.
Returns nullptr otherwise.
Derived & dart::common::Castable< Base >::asRef | ( | ) |
Casts to reference of Derived if Base is its base class. UB otherwise.
const Derived & dart::common::Castable< Base >::asRef | ( | ) | const |
Casts to reference of Derived if Base is its base class. UB otherwise.
|
private |
Casts to Base reference.
|
private |
Casts to Base const-reference.
bool dart::common::Castable< Base >::is | ( | ) | const |
Returns true if the types of this Base
and the template parameter (a base class) are identical.
This function is a syntactic sugar, which is identical to: (getType() == ShapeType::getStaticType()).
Example code: