cMHN 1.1
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
crtp.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_BASIC_CRTP_H
4#define pRC_CORE_BASIC_CRTP_H
5
7
8namespace pRC
9{
10 template<class T>
11 class CRTP
12 {
13 public:
14 constexpr operator T() const
15 {
16 return self();
17 }
18
19 using Derived = T;
20
21 protected:
22 ~CRTP() = default;
23 constexpr CRTP(CRTP const &) = default;
24 constexpr CRTP(CRTP &&) = default;
25 constexpr CRTP &operator=(CRTP const &) & = default;
26 constexpr CRTP &operator=(CRTP &&) & = default;
27 constexpr CRTP()
28 {
29 static_assert(IsBaseOf<CRTP, T>());
30 }
31
32 public:
33 constexpr decltype(auto) self() &
34 {
35 return static_cast<T &>(*this);
36 }
37
38 constexpr decltype(auto) self() const &
39 {
40 return static_cast<T const &>(*this);
41 }
42 };
43}
44#endif // pRC_CORE_BASIC_CRTP_H
Definition crtp.hpp:12
constexpr CRTP(CRTP const &)=default
constexpr CRTP()
Definition crtp.hpp:27
constexpr decltype(auto) self() const &
Definition crtp.hpp:38
~CRTP()=default
constexpr decltype(auto) self() &
Definition crtp.hpp:33
constexpr CRTP & operator=(CRTP &&) &=default
constexpr CRTP & operator=(CRTP const &) &=default
constexpr CRTP(CRTP &&)=default
pRC::Float<> T
Definition externs_nonTT.hpp:1
Definition cholesky.hpp:18
static constexpr auto makeConstantSequence()
Definition sequence.hpp:402