cMHN 1.2
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
identity.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_BASIC_IDENTITY_H
4#define pRC_CORE_BASIC_IDENTITY_H
5
7
8namespace pRC
9{
10 template<class T = Void>
11 struct Identity;
12
13 template<class T>
14 struct Identity<T const> : Identity<T>
15 {
16 };
17
18 template<IsVoid T>
19 struct Identity<T>
20 {
21 template<class F>
22 requires IsBool<F> || IsIntegral<F>
23 constexpr operator F() const
24 {
25 return Identity<F>()();
26 }
27 };
28
29 template<IsBool T>
30 struct Identity<T>
31 {
32 constexpr T operator()() const
33 {
34 return true;
35 }
36
37 template<class X>
39 constexpr T operator()(X &&value) const
40 {
41 return forward<X>(value);
42 }
43 };
44
45 template<IsIntegral T>
46 struct Identity<T>
47 {
48 constexpr T operator()() const
49 {
50 return 1;
51 }
52
53 template<class X>
55 constexpr T operator()(X &&value) const
56 {
57 return forward<X>(value);
58 }
59 };
60}
61#endif // pRC_CORE_BASIC_IDENTITY_H
Definition value.hpp:12
Definition concepts.hpp:58
Definition concepts.hpp:37
Definition concepts.hpp:70
int value
Definition gmock-actions_test.cc:1714
Definition cholesky.hpp:10
constexpr T operator()(X &&value) const
Definition identity.hpp:39
constexpr T operator()() const
Definition identity.hpp:32
Definition identity.hpp:11