7#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ALGORITHM_TRANSFORM_REDUCE_HPP_
8#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_ALGORITHM_TRANSFORM_REDUCE_HPP_
16#include "arene/base/algorithm/detail/generalized_transform_reduce.hpp"
17#include "arene/base/algorithm/detail/reduce_policy_movable_box.hpp"
18#include "arene/base/algorithm/detail/synthesize_range1_overload.hpp"
19#include "arene/base/algorithm/detail/traits.hpp"
22#include "arene/base/stdlib_choice/declval.hpp"
23#include "arene/base/stdlib_choice/enable_if.hpp"
24#include "arene/base/stdlib_choice/is_constructible.hpp"
25#include "arene/base/stdlib_choice/is_move_constructible.hpp"
26#include "arene/base/stdlib_choice/move.hpp"
27#include "arene/base/stdlib_choice/multiplies.hpp"
28#include "arene/base/stdlib_choice/plus.hpp"
39namespace algorithm_detail {
40namespace transform_reduce_detail {
43class transform_reduce_fn {
49 template <
class Invocable,
class... Iterator>
111 std::enable_if_t<std::is_move_constructible<Value>::value>,
121 iter_result_t<Transform&, InputIt1, InputIt2>>>,
125 iter_result_t<Transform&, InputIt1, InputIt2>,
130 iter_result_t<Transform&, InputIt1, InputIt2>,
131 iter_result_t<Transform&, InputIt1, InputIt2>>>> =
nullptr>
132 constexpr auto operator()(
144 std::is_nothrow_constructible<
145 typename reduce_policy_movable_box<Value>::value_type,
150 generalized_transform_reduce,
151 reduce_policy_movable_box<Value>,
155 typename reduce_policy_movable_box<Value>::value_type,
161 using value_policy = reduce_policy_movable_box<Value>;
163 return value_policy::access(
164 generalized_transform_reduce{}(
169 typename value_policy::value_type{
std::move(init)},
226 std::enable_if_t<std::is_move_constructible<Value>::value>,
236 iter_result_t<std::multiplies<>&, InputIt1, InputIt2>>>,
240 iter_result_t<std::multiplies<>&, InputIt1, InputIt2>,
245 iter_result_t<std::multiplies<>&, InputIt1, InputIt2>,
246 iter_result_t<std::multiplies<>&, InputIt1, InputIt2>>>> =
nullptr>
247 constexpr auto operator()(
323 std::enable_if_t<std::is_move_constructible<Value>::value>,
333 iter_result_t<Transform&, InputIt>>>,
337 iter_result_t<Transform&, InputIt>,
342 iter_result_t<Transform&, InputIt>,
343 iter_result_t<Transform&, InputIt>>>> =
nullptr>
344 constexpr auto operator()(
359 noexcept(reduce_policy_movable_box<Value>::assign(
360 std::declval<
typename reduce_policy_movable_box<Value>::value_type&>(),
362 reduce_policy_movable_box<Value>::access(
363 std::declval<
typename reduce_policy_movable_box<Value>::value_type&>()
372 using reduce_policy = reduce_policy_movable_box<Value>;
374 auto acc =
typename reduce_policy::value_type{
std::move(init)};
376 for (; first != last; ++first) {
377 reduce_policy::assign(
379 reduce(reduce_policy::access(acc), transform(*first))
383 return reduce_policy::access(acc);
396 algorithm_detail::synthesize_range1_overload_t<algorithm_detail::transform_reduce_detail::transform_reduce_fn>,
#define ARENE_CPP14_INLINE_VARIABLE(type, name)
Emulates C++17's inline variable declarations for function objects.
Definition cpp14_inline.hpp:69
static constexpr value_type value
Definition integral_constant.hpp:34
Definition accumulate.hpp:37
constexpr bool is_invocable_r_v
Determine if a functor type is invocable with the specified return and argument types.
typename invoke_result< Fn, Args... >::type invoke_result_t
The return type of a functor invoked with the specified arguments.
Definition is_invocable.hpp:271
constexpr bool is_nothrow_invocable_v
Determine if a functor type is no-throw invocable with the specified argument types.
typename constraints_impl::constraints< EnableIfs... >::type constraints
Helper used to express template constraints in a consistent way using std::enable_if_t.
Definition constraints.hpp:51
Definition accumulate.hpp:36
constexpr auto move(T &&value) noexcept -> remove_reference_t< T > &&
Cast a value to an rvalue.
Definition move.hpp:30
typename enable_if< Condition, Type >::type enable_if_t
Type alias to support constraining templates. Is an alias for the specified type if the Condition is ...
Definition enable_if.hpp:41
auto declval() noexcept -> T &&
A dummy function that is declared but not defined, with a user-specified return type,...