pRC
multi-purpose Tensor Train library for C++
Loading...
Searching...
No Matches
where.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_BASIC_FUNCTIONS_WHERE_H
4#define pRC_CORE_BASIC_FUNCTIONS_WHERE_H
5
8
9namespace pRC
10{
11 template<class TE, class T, If<IsBool<TE>> = 0>
12 static inline constexpr T where(TE const e, T &&a, T &&b)
13 {
14 return e ? a : b;
15 }
16
17 template<class TE, class T, If<IsBool<TE>> = 0>
18 static inline constexpr T const &where(TE const e, T const &a, T &b)
19 {
20 return e ? a : b;
21 }
22
23 template<class TE, class T, If<IsBool<TE>> = 0>
24 static inline constexpr T const &where(TE const e, T &a, T const &b)
25 {
26 return e ? a : b;
27 }
28
29 template<class TE, class XA, class XB, If<IsBool<TE>> = 0>
30 static inline constexpr auto where(TE const e, XA &&a, XB &&b)
31 {
33 return where(e, T(forward<XA>(a)), T(forward<XB>(b)));
34 }
35}
36#endif // pRC_CORE_BASIC_FUNCTIONS_WHERE_H
Definition cholesky.hpp:18
std::remove_reference_t< T > RemoveReference
Definition type_traits.hpp:56
static constexpr T where(TE const e, T &&a, T &&b)
Definition where.hpp:12
typename CommonTypes< Ts... >::Type Common
Definition common.hpp:55
static constexpr Conditional< IsSatisfied< C >, RemoveConstReference< X >, X > copy(X &&a)
Definition copy.hpp:13