Micro template library
A library for building device drivers
Vous ne pouvez pas sélectionner plus de 25 sujets
Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
|
- /*!
- * \file utl/core/crtp.h
- * \brief CRTP idiom support header
- */
- #ifndef __utl_impl_crtp_h__
- #define __utl_impl_crtp_h__
-
- #include <utl/core/impl.h>
-
- /*!
- * \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<T*>(this); } \
- constexpr const T& impl() const { return *static_cast<const T*>(this); }
-
- }
- //!@}
- #endif /* __utl_impl_crtp_h__ */
|