template<typename ConcreteType, template< typename... > typename CRTPBaseType, typename... TParams>
struct m::crtp< ConcreteType, CRTPBaseType, TParams >
A helper class to define CRTP class hierarchies.
Taken from An Implementation Helper For The Curiously Recurring Template Pattern - Fluent C++.
This CRTP helper ensures that the
- Template Parameters
-
ConcreteType | actually inherits from |
CRTPBaseType. | The helper defines a method actual() that allows for safely casting the CRTP base type |
CRTPBaseType | to the |
ConcreteType,properly | const -quanified. |
A class that wants to make use of CRTP should inherit from this helper. The following example demonstrates this:
template<typename ConcreteType>
struct CRTPBase :
crtp<ConcreteType, CRTPBase>
{
using crtp<ConcreteType, CRTPBase>::actual;
};
A helper class to define CRTP class hierarchies.
It is also possible for the class implementing CRTP to take additional template parameters:
template<typename ConcreteType, typename T1, typename T2>
struct CRTPBase :
crtp<ConcreteType, CRTPBase, T1, T2>
{
using crtp<ConcreteType, CRTPBase, T1, T2>::actual;
};
This should also work with variadic templates:
template<typename ConcreteType, typename... Args>
struct CRTPBase :
crtp<ConcreteType, CRTPBase, Args...>
{
using crtp<ConcreteType, CRTPBase, Args...>::actual;
};
Definition at line 49 of file crtp.hpp.