14#ifndef RANGES_V3_CONTAINER_ACTION_HPP
15#define RANGES_V3_CONTAINER_ACTION_HPP
31#include <range/v3/utility/static_const.hpp>
33#include <range/v3/detail/prologue.hpp>
41 template<
typename Fun>
54 struct action_closure_base_
61 template(
typename ActionFn,
typename Rng)(
62 concept (invocable_action_closure_)(ActionFn, Rng),
63 !derived_from<invoke_result_t<ActionFn, Rng>, detail::action_closure_base_>
67 template<
typename ActionFn,
typename Rng>
68 CPP_concept invocable_action_closure =
69 invocable<ActionFn, Rng> &&
74 struct RANGES_STRUCT_WITH_ADL_BARRIER(action_closure_base)
75 : detail::action_closure_base_
79 template(
typename Rng,
typename ActionFn)(
80 requires (!std::is_lvalue_reference<Rng>::value) AND
81 range<Rng> AND invocable_action_closure<ActionFn, Rng &>)
83 operator|(Rng && rng, action_closure<ActionFn> act)
85 return aux::move(
static_cast<ActionFn &&
>(act)(rng));
88#ifndef RANGES_WORKAROUND_CLANG_43400
89 template<
typename Rng,
typename ActionFn>
92 action_closure<ActionFn>
const &)
93 -> CPP_broken_friend_ret(Rng)(
94 requires range<Rng>) =
delete;
100 template<
typename ActionFn,
typename Pipeable>
101 friend constexpr auto operator|(action_closure<ActionFn> act, Pipeable pipe)
102 -> CPP_broken_friend_ret(action_closure<composed<Pipeable, ActionFn>>)(
103 requires (is_pipeable_v<Pipeable>))
105 return make_action_closure(compose(
static_cast<Pipeable &&
>(pipe),
106 static_cast<ActionFn &&
>(act)));
109 template<
typename Rng,
typename ActionFn>
110 friend constexpr auto operator|=(Rng & rng, action_closure<ActionFn> act)
111 -> CPP_broken_friend_ret(Rng &)(
112 requires range<Rng> && invocable<ActionFn, Rng &>)
114 static_cast<ActionFn &&
>(act)(rng);
120#ifdef RANGES_WORKAROUND_CLANG_43400
122 namespace RANGES_ADL_BARRIER_FOR(action_closure_base)
124 template(
typename Rng,
typename ActionFn)(
128 action_closure<ActionFn>
const &)
137 template<
typename ActionFn>
139 : action_closure_base
145 : ActionFn(
static_cast<ActionFn &&
>(fn))
151 struct action_access_
153 template<
typename Action>
157 template<
typename... Ts,
typename A = Action>
158 static constexpr auto CPP_auto_fun(bind)(Ts &&... ts)
160 return A::bind(
static_cast<Ts &&
>(ts)...)
166 using action_access RANGES_DEPRECATED(
167 "action_access and actions::action<> are deprecated. Please "
168 "replace action<> with action_closure<> and discontinue use of "
169 "action_access.") = action_access_;
174 struct make_action_fn_
176 template<
typename Fun>
177 constexpr old_action_<Fun> operator()(Fun fun)
const
179 return old_action_<Fun>{
static_cast<Fun &&
>(fun)};
182 using make_action_fn RANGES_DEPRECATED(
183 "make_action_fn is deprecated. Please use "
184 "make_action_closure instead.") = make_action_fn_;
189 "make_action and actions::action<> has been deprecated. Please switch to "
190 "make_action_closure and action::action_closure.")
191 RANGES_INLINE_VAR constexpr auto & make_action =
192 static_const<make_action_fn_>::value;
195 template<typename Action>
196 struct old_action_ : pipeable_base
200 friend pipeable_access;
203 old_action_() =
default;
205 constexpr explicit old_action_(Action a)
noexcept(
206 std::is_nothrow_move_constructible<Action>::value)
207 : act_(detail::move(a))
211 template(
typename Rng,
typename... Rest)(
212 requires range<Rng> AND invocable<Action const &, Rng &, Rest...>)
213 invoke_result_t<Action
const &, Rng &, Rest...>
214 operator()(Rng & rng, Rest &&... rest)
const
216 return invoke(act_, rng,
static_cast<Rest &&
>(rest)...);
221 template(
typename... Rest,
typename A = Action)(
222 requires (
sizeof...(Rest) != 0))
223 auto CPP_auto_fun(
operator())(Rest &&... rest)(
const)
225 return make_action_fn_{}(
226 action_access_::impl<A>::bind(act_,
227 static_cast<Rest &&
>(rest)...))
232 template<
typename Action>
233 using action RANGES_DEPRECATED(
234 "The actions::action<> template is deprecated. Please switch to "
235 "action_closure") = old_action_<Action>;
239 template<
typename ActionFn>
240 RANGES_INLINE_VAR
constexpr bool is_pipeable_v<actions::action_closure<ActionFn>> =
245#include <range/v3/detail/epilogue.hpp>
The invocable_action_closure_ concept.
typename Fn::template invoke< Args... > invoke
Evaluate the invocable Fn with the arguments Args.
Definition meta.hpp:541
Definition action.hpp:141