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_VALUE_IDENTITY_H
4#define pRC_CORE_VALUE_IDENTITY_H
5
8
9namespace pRC
10{
11 template<class T>
12 struct Identity<T, If<IsValue<T>>>
13 {
14 constexpr T operator()()
15 {
16 return 1;
17 }
18
19 template<class X, If<IsConstructible<T, X>> = 0>
20 constexpr T operator()(X &&value)
21 {
22 return forward<X>(value);
23 }
24 };
25
26 template<>
27 struct Identity<Float<16>>
28 {
30 {
31 return BFloat16::FromRepresentation(0x3F80);
32 }
33
34 template<class X, If<IsConstructible<Float<16>, X>> = 0>
35 constexpr Float<16> operator()(X &&value)
36 {
37 return forward<X>(value);
38 }
39 };
40}
41#endif // pRC_CORE_VALUE_IDENTITY_H
static constexpr auto FromRepresentation(Representation const rep)
Definition bfloat16.hpp:26
Definition cholesky.hpp:18
static constexpr auto makeConstantSequence()
Definition sequence.hpp:402
std::enable_if_t< B{}, int > If
Definition type_traits.hpp:68
Any< IsFloat< T >, IsInteger< T > > IsValue
Definition type_traits.hpp:72
constexpr Float< 16 > operator()()
Definition identity.hpp:29
constexpr Float< 16 > operator()(X &&value)
Definition identity.hpp:35
constexpr T operator()(X &&value)
Definition identity.hpp:20
constexpr T operator()()
Definition identity.hpp:14
Definition type_traits.hpp:262