cMHN 1.2
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
min.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_BASIC_FUNCTIONS_MIN_H
4#define pRC_CORE_BASIC_FUNCTIONS_MIN_H
5
9
10namespace pRC
11{
12 template<class X>
13 static inline constexpr decltype(auto) min(X &&a)
14 {
15 return as(forward<X>(a));
16 }
17
18 template<class XA, class XB>
19 requires IsInvocable<Less, XA, XB>
20 static inline constexpr decltype(auto) min(XA &&a, XB &&b)
21 {
22 return where(a < b, forward<XA>(a), forward<XB>(b));
23 }
24
25 template<class XA, class XB, class... Xs>
26 requires IsInvocable<Less, XA, XB> &&
27 (IsInvocable<Less, ResultOf<Where, ResultOf<Less, XA, XB>, XA, XB>,
28 Xs> &&
29 ...)
30 static inline constexpr decltype(auto) min(XA &&a, XB &&b, Xs &&...args)
31 {
32 return min(min(forward<XA>(a), forward<XB>(b)), forward<Xs>(args)...);
33 }
34}
35#endif // pRC_CORE_BASIC_FUNCTIONS_MIN_H
Definition cholesky.hpp:10
static constexpr decltype(auto) where(TE const e, XA &&a, XB &&b)
Definition where.hpp:11
static constexpr decltype(auto) min(X &&a)
Definition min.hpp:13
static constexpr RemoveConst< X > as(X &&a)
Definition basics.hpp:83