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