6#ifndef MIMICPP_POLICIES_FINALIZER_POLICIES_HPP
7#define MIMICPP_POLICIES_FINALIZER_POLICIES_HPP
22 template <
typename Action>
23 requires std::same_as<Action, std::remove_cvref_t<Action>>
24 && std::is_move_constructible_v<Action>
30 noexcept(std::is_nothrow_move_constructible_v<Action>)
31 : m_Action{std::move(action)}
35 template <
typename Return,
typename... Args>
36 requires std::invocable<Action&,
const call::Info<Return, Args...>&>
38 std::invoke_result_t<Action&,
const call::Info<Return, Args...>&>,
43 std::is_nothrow_invocable_v<Action&,
const call::Info<Return, Args...>&>
46 return static_cast<Return
>(
47 std::invoke(m_Action,
call));
54 template <
typename Exception>
55 requires(!std::is_reference_v<Exception>)
56 && std::copyable<Exception>
61 explicit constexpr Throws(Exception exception)
noexcept(std::is_nothrow_move_constructible_v<Exception>)
62 : m_Exception{std::move(exception)}
61 explicit constexpr Throws(Exception exception)
noexcept(std::is_nothrow_move_constructible_v<Exception>) {
…}
66 template <
typename Return,
typename... Args>
74 Exception m_Exception;
109 template <
typename Fun>
110 requires std::invocable<std::remove_cvref_t<Fun>&>
111 && (!std::is_void_v<std::invoke_result_t<std::remove_cvref_t<Fun>&>>)
114 noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<Fun>, Fun>)
117 [fn = std::forward<Fun>(fun)]([[maybe_unused]]
const auto&
call)
mutable noexcept(
118 std::is_nothrow_invocable_v<
decltype(fun)>) ->
decltype(
auto) {
119 return std::invoke(fn);
140 template <
typename T>
141 requires std::copyable<std::remove_cvref_t<T>>
144 noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<T>, T>)
147 [v = std::forward<T>(value)]([[maybe_unused]]
const auto&
call)
mutable noexcept ->
auto& {
148 return static_cast<std::unwrap_reference_t<decltype(v)
>&>(v);
164 template <std::size_t index, std::size_t... otherIndices,
typename Action>
167 noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<Action>, Action>)
169 using arg_selector_t = detail::args_selector_fn<
170 std::add_lvalue_reference_t,
171 std::index_sequence<index, otherIndices...>>;
172 using apply_strategy_t = detail::arg_list_forward_apply_fn;
176 detail::apply_args_fn{
179 std::forward<Action>(action))};
192 template <
typename Action>
195 noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<Action>, Action>)
197 using arg_selector_t = detail::all_args_selector_fn<std::add_lvalue_reference_t>;
198 using apply_strategy_t = detail::arg_list_forward_apply_fn;
202 detail::apply_args_fn{
205 std::forward<Action>(action))};
215 template <std::
size_t index>
219 using arg_selector_t = detail::args_selector_fn<
220 std::add_rvalue_reference_t,
221 std::index_sequence<index>>;
222 using apply_strategy_t = detail::arg_list_forward_apply_fn;
226 detail::apply_args_fn{
241 template <
typename T>
242 requires std::copyable<std::remove_cvref_t<T>>
245 noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<T>, T>)
248 std::forward<T>(exception)};
Definition FinalizerPolicies.hpp:26
constexpr Return finalize_call(const call::Info< Return, Args... > &call) noexcept(std::is_nothrow_invocable_v< Action &, const call::Info< Return, Args... > & > &¬hrow_explicitly_convertible_to< std::invoke_result_t< Action &, const call::Info< Return, Args... > & >, Return >)
Definition FinalizerPolicies.hpp:41
constexpr ReturnsResultOf(Action &&action) noexcept(std::is_nothrow_move_constructible_v< Action >)
Definition FinalizerPolicies.hpp:29
Definition FinalizerPolicies.hpp:58
constexpr Return finalize_call(const call::Info< Return, Args... > &call)
Definition FinalizerPolicies.hpp:67
constexpr Throws(Exception exception) noexcept(std::is_nothrow_move_constructible_v< Exception >)
Definition FinalizerPolicies.hpp:61
Definition Utility.hpp:53
Definition Utility.hpp:59
constexpr auto returns_apply_all_result_of(Action &&action) noexcept(std::is_nothrow_constructible_v< std::remove_cvref_t< Action >, Action >)
During the finalization step, all call arguments are applied on the given action.
Definition FinalizerPolicies.hpp:194
constexpr auto returns_apply_result_of(Action &&action) noexcept(std::is_nothrow_constructible_v< std::remove_cvref_t< Action >, Action >)
During the finalization step, the selected call arguments are applied on the given action.
Definition FinalizerPolicies.hpp:166
constexpr auto returns(T &&value) noexcept(std::is_nothrow_constructible_v< std::remove_cvref_t< T >, T >)
During the finalization step, the stored value is returned.
Definition FinalizerPolicies.hpp:143
consteval auto returns_arg() noexcept
During the finalization step, the selected call argument is returned.
Definition FinalizerPolicies.hpp:217
constexpr auto returns_result_of(Fun &&fun) noexcept(std::is_nothrow_constructible_v< std::remove_cvref_t< Fun >, Fun >)
During the finalization step, the invocation result of the given function is returned.
Definition FinalizerPolicies.hpp:113
Definition ArgRequirementPolicies.hpp:22
Definition FinalizerPolicies.hpp:79