14 template <
typename T,
typename BinaryOp,
typename IdentityProv
ider = default_
identity_prov
ider<T>>
16 static_assert(std::is_same_v<T, typename IdentityProvider::value_type>);
30 return IdentityProvider();
34 static constexpr
auto bop_ = BinaryOp();
39 static_assert(std::is_arithmetic_v<T>);
41 static constexpr T
value = T{1};
48 static_assert(std::is_arithmetic_v<T>);
50 static constexpr T
value = std::numeric_limits<T>::lowest();
57 static_assert(std::is_arithmetic_v<T>);
64 template <
typename T =
void>
73 template <
typename T,
typename U>
75 return std::min(std::forward<T>(v), std::forward<U>(u));
79 template <
typename T =
void>
88 template <
typename T,
typename U>
90 return std::max(std::forward<T>(t), std::forward<U>(u));
100 template <
typename T>
103 template <
typename T>
106 template <
typename T>
113 acc.second =
std::max(acc.second, x);
117 acc_l.first =
std::min(acc_l.first, acc_r.first);
118 acc_l.second =
std::max(acc_l.second, acc_r.second);
122 (*this)(acc_r, acc_l);
133 template <
typename Acc,
typename... Fns>
137 : Fns(std::forward<Fns>(fns))... {}
138 using Fns::operator()...;
143 template <
typename T,
typename =
void>
144 struct type_or_void {
148 template <
typename T>
149 struct type_or_void<T, std::void_t<typename T::type>> {
150 using type =
typename T::type;
154 template <
typename T>
155 using type_or_void_t =
typename type_or_void<T>::type;
157 template <
typename...>
158 struct identity_retval {
162 template <
typename Fn,
typename... Rest>
163 struct identity_retval<Fn, Rest...> {
166 using type = std::conditional_t<std::is_invocable_v<Fn>,
167 type_or_void_t<std::invoke_result<Fn>>,
168 typename identity_retval<Rest...>::type>;
171 template <
typename... Fns>
172 using identity_retval_t =
typename identity_retval<std::remove_reference_t<Fns>...>::type;
176 template <
typename... Fns>
178 using acc_t = internal::identity_retval_t<Fns...>;
179 static_assert(!std::is_void_v<acc_t>,
180 "Please define an identity function that returns a nonvoid value.");
Definition: reducer.hpp:5
monoid< T, min_functor<>, highest< T > > min
Definition: reducer.hpp:101
monoid< T, max_functor<>, lowest< T > > max
Definition: reducer.hpp:104
decltype(auto) make_reducer(Fns &&... fns)
Definition: reducer.hpp:177
Definition: reducer.hpp:8
value_type operator()() const
Definition: reducer.hpp:11
T value_type
Definition: reducer.hpp:9
Definition: reducer.hpp:56
T value_type
Definition: reducer.hpp:58
constexpr value_type operator()() const noexcept
Definition: reducer.hpp:61
static constexpr T value
Definition: reducer.hpp:59
Definition: reducer.hpp:47
static constexpr T value
Definition: reducer.hpp:50
T value_type
Definition: reducer.hpp:49
constexpr value_type operator()() const noexcept
Definition: reducer.hpp:52
constexpr auto operator()(T &&t, U &&u) const
Definition: reducer.hpp:89
Definition: reducer.hpp:80
constexpr T operator()(const T &x, const T &y) const
Definition: reducer.hpp:81
constexpr auto operator()(T &&v, U &&u) const
Definition: reducer.hpp:74
Definition: reducer.hpp:65
constexpr T operator()(const T &x, const T &y) const
Definition: reducer.hpp:66
Definition: reducer.hpp:107
void operator()(accumulator_type &acc, const value_type &x) const
Definition: reducer.hpp:111
accumulator_type operator()() const
Definition: reducer.hpp:125
void operator()(const accumulator_type &acc_l, accumulator_type &acc_r) const
Definition: reducer.hpp:121
void operator()(accumulator_type &acc_l, const accumulator_type &acc_r) const
Definition: reducer.hpp:116
T value_type
Definition: reducer.hpp:108
std::pair< T, T > accumulator_type
Definition: reducer.hpp:109
Definition: reducer.hpp:15
T value_type
Definition: reducer.hpp:18
void operator()(const T &l, T &r) const
Definition: reducer.hpp:25
void operator()(T &l, const T &r) const
Definition: reducer.hpp:21
T accumulator_type
Definition: reducer.hpp:19
T operator()() const
Definition: reducer.hpp:29
Definition: reducer.hpp:38
constexpr value_type operator()() const noexcept
Definition: reducer.hpp:43
static constexpr T value
Definition: reducer.hpp:41
T value_type
Definition: reducer.hpp:40
Definition: reducer.hpp:134
reducer_generic(Fns &&... fns)
Definition: reducer.hpp:136
Acc accumulator_type
Definition: reducer.hpp:135