Micro template library
A library for building device drivers
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- /*!
- * \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__ */
|