cMHN 1.2
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() = default;
28
29 public:
30 constexpr decltype(auto) self() &
31 {
32 return static_cast<T &>(*this);
33 }
34
35 constexpr decltype(auto) self() const &
36 {
37 return static_cast<T const &>(*this);
38 }
39 };
40}
41#endif // pRC_CORE_BASIC_CRTP_H
Definition crtp.hpp:12
constexpr CRTP(CRTP const &)=default
constexpr decltype(auto) self() const &
Definition crtp.hpp:35
~CRTP()=default
constexpr CRTP()=default
constexpr decltype(auto) self() &
Definition crtp.hpp:30
constexpr CRTP & operator=(CRTP &&) &=default
constexpr CRTP & operator=(CRTP const &) &=default
constexpr CRTP(CRTP &&)=default
Definition value.hpp:12
pRC::Float<> T
Definition externs_nonTT.hpp:1
Definition cholesky.hpp:10