6#ifndef MIMICPP_POLICIES_SIDE_EFFECT_POLICIES_HPP
7#define MIMICPP_POLICIES_SIDE_EFFECT_POLICIES_HPP
15#ifndef MIMICPP_DETAIL_IS_MODULE
20 #include <type_traits>
26 template <
typename Action>
34 Action&& action)
noexcept(std::is_nothrow_move_constructible_v<Action>)
35 : m_Action{std::move(action)}
51 template <
typename Return,
typename... Args>
64 template <
typename Return,
typename... Args>
65 requires std::invocable<Action&,
const call::Info<Return, Args...>&>
67 noexcept(std::is_nothrow_invocable_v<Action&,
const call::Info<Return, Args...>&>)
69 std::invoke(m_Action, info);
107 template <std::
size_t index,
typename Action>
110 noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<Action>, Action>)
112 using arg_selector_t = detail::args_selector_fn<
113 std::add_lvalue_reference_t,
114 std::index_sequence<index>>;
115 using apply_strategy_t = detail::arg_list_forward_apply_fn;
119 detail::apply_args_fn{
122 std::forward<Action>(action))};
135 template <std::size_t index, std::size_t... additionalIndices,
typename Action>
138 noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<Action>, Action>)
140 using arg_selector_t = detail::args_selector_fn<
141 std::add_lvalue_reference_t,
142 std::index_sequence<index, additionalIndices...>>;
143 using apply_strategy_t = detail::arg_list_forward_apply_fn;
147 detail::apply_args_fn{
150 std::forward<Action>(action))};
159 template <
typename Action>
162 noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<Action>, Action>)
164 using arg_selector_t = detail::all_args_selector_fn<std::add_lvalue_reference_t>;
165 using apply_strategy_t = detail::arg_list_forward_apply_fn;
169 detail::apply_args_fn{
172 std::forward<Action>(action))};
181 template <std::invocable Action>
184 noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<Action>, Action>)
187 [fn = std::forward<Action>(action)]([[maybe_unused]]
const auto&
call)
mutable noexcept(
188 std::is_nothrow_invocable_v<Action&>) {
#define MIMICPP_DETAIL_MODULE_EXPORT
Definition Config.hpp:19
Definition SideEffectPolicies.hpp:28
static constexpr bool matches(const call::Info< Return, Args... > &) noexcept
Definition SideEffectPolicies.hpp:53
static std::nullopt_t describe() noexcept
Definition SideEffectPolicies.hpp:59
~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:66
SideEffectAction & operator=(const SideEffectAction &)=delete
static constexpr bool is_satisfied() noexcept
Definition SideEffectPolicies.hpp:46
SideEffectAction(SideEffectAction &&)=default
constexpr SideEffectAction(Action &&action) noexcept(std::is_nothrow_move_constructible_v< Action >)
Definition SideEffectPolicies.hpp:33
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:161
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:109
constexpr auto invoke(Action &&action) noexcept(std::is_nothrow_constructible_v< std::remove_cvref_t< Action >, Action >)
Invokes the given function.
Definition SideEffectPolicies.hpp:183
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:137
Definition ArgRequirementPolicies.hpp:28
Definition SideEffectPolicies.hpp:78