6#ifndef MIMICPP_POLICIES_SIDE_EFFECT_POLICIES_HPP
7#define MIMICPP_POLICIES_SIDE_EFFECT_POLICIES_HPP
21 template <
typename Action>
29 Action&& action)
noexcept(std::is_nothrow_move_constructible_v<Action>)
30 : m_Action{std::move(action)}
46 template <
typename Return,
typename... Args>
59 template <
typename Return,
typename... Args>
60 requires std::invocable<Action&,
const call::Info<Return, Args...>&>
62 noexcept(std::is_nothrow_invocable_v<Action&,
const call::Info<Return, Args...>&>)
64 std::invoke(m_Action, info);
102 template <std::
size_t index,
typename Action>
105 noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<Action>, Action>)
107 using arg_selector_t = detail::args_selector_fn<
108 std::add_lvalue_reference_t,
109 std::index_sequence<index>>;
110 using apply_strategy_t = detail::arg_list_forward_apply_fn;
114 detail::apply_args_fn{
117 std::forward<Action>(action))};
130 template <std::size_t index, std::size_t... additionalIndices,
typename Action>
133 noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<Action>, Action>)
135 using arg_selector_t = detail::args_selector_fn<
136 std::add_lvalue_reference_t,
137 std::index_sequence<index, additionalIndices...>>;
138 using apply_strategy_t = detail::arg_list_forward_apply_fn;
142 detail::apply_args_fn{
145 std::forward<Action>(action))};
154 template <
typename Action>
157 noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<Action>, Action>)
159 using arg_selector_t = detail::all_args_selector_fn<std::add_lvalue_reference_t>;
160 using apply_strategy_t = detail::arg_list_forward_apply_fn;
164 detail::apply_args_fn{
167 std::forward<Action>(action))};
176 template <std::invocable Action>
179 noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<Action>, Action>)
182 [fn = std::forward<Action>(action)]([[maybe_unused]]
const auto&
call)
mutable noexcept(
183 std::is_nothrow_invocable_v<Action&>) {
Definition SideEffectPolicies.hpp:23
static constexpr bool matches(const call::Info< Return, Args... > &) noexcept
Definition SideEffectPolicies.hpp:48
static std::nullopt_t describe() noexcept
Definition SideEffectPolicies.hpp:54
~SideEffectAction()=default
constexpr void consume(const call::Info< Return, Args... > &info) noexcept(std::is_nothrow_invocable_v< Action &, const call::Info< Return, Args... > & >)
Definition SideEffectPolicies.hpp:61
SideEffectAction & operator=(const SideEffectAction &)=delete
static constexpr bool is_satisfied() noexcept
Definition SideEffectPolicies.hpp:41
SideEffectAction(SideEffectAction &&)=default
constexpr SideEffectAction(Action &&action) noexcept(std::is_nothrow_move_constructible_v< Action >)
Definition SideEffectPolicies.hpp:28
SideEffectAction & operator=(SideEffectAction &&)=default
SideEffectAction(const SideEffectAction &)=delete
constexpr auto apply_all(Action &&action) noexcept(std::is_nothrow_constructible_v< std::remove_cvref_t< Action >, Action >)
Applies all arguments on the given action.
Definition SideEffectPolicies.hpp:156
constexpr auto apply_arg(Action &&action) noexcept(std::is_nothrow_constructible_v< std::remove_cvref_t< Action >, Action >)
Applies the argument at the specified index on the given action.
Definition SideEffectPolicies.hpp:104
constexpr auto invoke(Action &&action) noexcept(std::is_nothrow_constructible_v< std::remove_cvref_t< Action >, Action >)
Invokes the given function.
Definition SideEffectPolicies.hpp:178
constexpr auto apply_args(Action &&action) noexcept(std::is_nothrow_constructible_v< std::remove_cvref_t< Action >, Action >)
Applies the arguments at the specified index and in that order on the given action.
Definition SideEffectPolicies.hpp:132
Definition ArgRequirementPolicies.hpp:22
Definition SideEffectPolicies.hpp:73