Tatooine
crtp.h
Go to the documentation of this file.
1#ifndef TATOOINE_CRTP_H
2#define TATOOINE_CRTP_H
3//==============================================================================
4namespace tatooine {
5//==============================================================================
6template <typename Derived>
7struct crtp {
8 using derived_type = Derived;
9 //----------------------------------------------------------------------------
11 [[nodiscard]] constexpr auto as_derived() -> derived_type& {
12 return static_cast<derived_type&>(*this);
13 }
14 //----------------------------------------------------------------------------
16 [[nodiscard]] constexpr auto as_derived() const -> derived_type const& {
17 return static_cast<derived_type const&>(*this);
18 }
19};
20//==============================================================================
21} // namespace tatooine
22//==============================================================================
23#endif
Definition: algorithm.h:6
Definition: crtp.h:7
constexpr auto as_derived() -> derived_type &
returns casted as_derived data
Definition: crtp.h:11
constexpr auto as_derived() const -> derived_type const &
returns casted as_derived data
Definition: crtp.h:16
Derived derived_type
Definition: crtp.h:8