pRC
multi-purpose Tensor Train library for C++
Loading...
Searching...
No Matches
unit.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_VALUE_UNIT_H
4#define pRC_CORE_VALUE_UNIT_H
5
8
9namespace pRC
10{
16 template<class T>
17 struct Unit<T, If<IsValue<T>>>
18 {
22 constexpr auto operator()()
23 {
24 return identity<T>();
25 }
26
35 template<class X, If<IsConstructible<T, X>> = 0>
36 constexpr auto operator()(X &&value)
37 {
38 return identity<T>(forward<X>(value));
39 }
40 };
41}
42#endif // pRC_CORE_VALUE_UNIT_H
Definition cholesky.hpp:18
std::enable_if_t< B{}, int > If
Definition type_traits.hpp:68
static constexpr Conditional< IsSatisfied< C >, RemoveConstReference< X >, X > copy(X &&a)
Definition copy.hpp:13
Any< IsFloat< T >, IsInteger< T > > IsValue
Definition type_traits.hpp:72
constexpr auto operator()()
Returns the unit, i.e. 1.
Definition unit.hpp:22
constexpr auto operator()(X &&value)
Returns a scaled unit, for value types the scaling factor is returned directly.
Definition unit.hpp:36
Definition type_traits.hpp:265