cMHN 1.1
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>
11 struct Identity<T, If<IsBool<T>>>
12 {
13 constexpr T operator()()
14 {
15 return true;
16 }
17
18 template<class X, If<IsConstructible<T, X>> = 0>
19 constexpr T operator()(X &&value)
20 {
21 return forward<X>(value);
22 }
23 };
24
25 template<class T>
27 {
28 constexpr T operator()()
29 {
30 return 1;
31 }
32
33 template<class X, If<IsConstructible<T, X>> = 0>
34 constexpr T operator()(X &&value)
35 {
36 return forward<X>(value);
37 }
38 };
39
40 template<>
41 struct Identity<Void<>>
42 {
43 template<class T, If<Any<IsBool<T>, IsIntegral<T>>> = 0>
44 constexpr operator T() const
45 {
46 return Identity<T>()();
47 }
48 };
49}
50#endif // pRC_CORE_BASIC_IDENTITY_H
pRC::Float<> T
Definition externs_nonTT.hpp:1
Definition cholesky.hpp:18
static constexpr auto makeConstantSequence()
Definition sequence.hpp:402
std::enable_if_t< B{}, int > If
Definition type_traits.hpp:68
void Void
Definition type_traits.hpp:16
All< std::is_integral< T >, Not< IsBool< T > > > IsIntegral
Definition type_traits.hpp:180
constexpr T operator()(X &&value)
Definition identity.hpp:19
constexpr T operator()()
Definition identity.hpp:13
constexpr T operator()()
Definition identity.hpp:28
constexpr T operator()(X &&value)
Definition identity.hpp:34
Definition type_traits.hpp:262
Definition type_traits.hpp:99