qb  2.0.0.0
C++17 Actor Framework
qb Issue Watch Star Fork Follow @isndev
Loading...
Searching...
No Matches
qb::crtp< T > Struct Template Reference

Base class for implementing the Curiously Recurring Template Pattern (CRTP). More...

#include <type_traits.h>

Public Member Functions

T & impl () noexcept
 Access the derived class instance.
T const & impl () const noexcept
 Access the derived class instance (const version)

Detailed Description

template<typename T>
struct qb::crtp< T >

Base class for implementing the Curiously Recurring Template Pattern (CRTP).

This class provides helper methods impl() to safely cast the base class pointer/reference to the derived class type T. This is the core mechanism of CRTP, enabling static polymorphism and code reuse by allowing base classes to access members of their derived classes.

Template Parameters
TThe derived class type that inherits from crtp<T>.

Member Function Documentation

◆ impl() [1/2]

template<typename T>
T & qb::crtp< T >::impl ( )
inlinenoexcept

Access the derived class instance.

Returns
Reference to the derived class

◆ impl() [2/2]

template<typename T>
T const & qb::crtp< T >::impl ( ) const
inlinenoexcept

Access the derived class instance (const version)

Returns
Const reference to the derived class