/*! * \file utl/core/crtp.h * \brief CRTP idiom support header */ #ifndef __utl_impl_crtp_h__ #define __utl_impl_crtp_h__ #include /*! * \defgroup crtp CRTP idiom support header * \ingroup core * * utl supports both CRTP idiom and dynamic polymorphism. By default * CRTP is the preferred way. If the user need virtuals then instead of * CRTP type, the \c virtual_tag can passed to base class. The rest * will handled by utl automatically. * * \sa utl::virtual_tag */ //!@{ namespace utl { //! CRTP support tag type struct crtp_tag { }; //! virtual support tag type struct virtual_tag { }; //! \def CRTP boilerplate lines #define _CRTP_IMPL(T) \ constexpr T& impl() { return *static_cast(this); } \ constexpr const T& impl() const { return *static_cast(this); } } //!@} #endif /* __utl_impl_crtp_h__ */