6#ifndef MIMICPP_POLICIES_FINALIZER_POLICIES_HPP
7#define MIMICPP_POLICIES_FINALIZER_POLICIES_HPP
16#ifndef MIMICPP_DETAIL_IS_MODULE
19 #include <type_traits>
25 template <
typename Action>
26 requires std::same_as<Action, std::remove_cvref_t<Action>>
27 && std::is_move_constructible_v<Action>
33 noexcept(std::is_nothrow_move_constructible_v<Action>)
34 : m_Action{std::move(action)}
38 template <
typename Return,
typename... Args>
39 requires std::invocable<Action&,
const call::Info<Return, Args...>&>
41 std::invoke_result_t<Action&,
const call::Info<Return, Args...>&>,
46 std::is_nothrow_invocable_v<Action&,
const call::Info<Return, Args...>&>
49 return static_cast<Return
>(
50 std::invoke(m_Action,
call));
57 template <
typename Exception>
58 requires(!std::is_reference_v<Exception>)
59 && std::copyable<Exception>
64 explicit constexpr Throws(Exception exception)
noexcept(std::is_nothrow_move_constructible_v<Exception>)
65 : m_Exception{std::move(exception)}
69 template <
typename Return,
typename... Args>
77 Exception m_Exception;
112 template <
typename Fun>
113 requires std::invocable<std::remove_cvref_t<Fun>&>
114 && (!std::is_void_v<std::invoke_result_t<std::remove_cvref_t<Fun>&>>)
117 noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<Fun>, Fun>)
120 [fn = std::forward<Fun>(fun)]([[maybe_unused]]
const auto&
call)
mutable noexcept(
121 std::is_nothrow_invocable_v<
decltype(fun)>) ->
decltype(
auto) {
122 return std::invoke(fn);
143 template <
typename T>
144 requires std::copyable<std::remove_cvref_t<T>>
147 noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<T>, T>)
150 [v = std::forward<T>(value)]([[maybe_unused]]
const auto&
call)
mutable noexcept ->
auto& {
151 return static_cast<std::unwrap_reference_t<decltype(v)
>&>(v);
167 template <std::size_t index, std::size_t... otherIndices,
typename Action>
170 noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<Action>, Action>)
172 using arg_selector_t = detail::args_selector_fn<
173 std::add_lvalue_reference_t,
174 std::index_sequence<index, otherIndices...>>;
175 using apply_strategy_t = detail::arg_list_forward_apply_fn;
179 detail::apply_args_fn{
182 std::forward<Action>(action))};
195 template <
typename Action>
198 noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<Action>, Action>)
200 using arg_selector_t = detail::all_args_selector_fn<std::add_lvalue_reference_t>;
201 using apply_strategy_t = detail::arg_list_forward_apply_fn;
205 detail::apply_args_fn{
208 std::forward<Action>(action))};
218 template <std::
size_t index>
222 using arg_selector_t = detail::args_selector_fn<
223 std::add_rvalue_reference_t,
224 std::index_sequence<index>>;
225 using apply_strategy_t = detail::arg_list_forward_apply_fn;
229 detail::apply_args_fn{
244 template <
typename T>
245 requires std::copyable<std::remove_cvref_t<T>>
248 noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<T>, T>)
251 std::forward<T>(exception)};
#define MIMICPP_DETAIL_MODULE_EXPORT
Definition Config.hpp:19
Definition FinalizerPolicies.hpp:29
constexpr Return finalize_call(const call::Info< Return, Args... > &call) noexcept(std::is_nothrow_invocable_v< Action &, const call::Info< Return, Args... > & > &&util::nothrow_explicitly_convertible_to< std::invoke_result_t< Action &, const call::Info< Return, Args... > & >, Return >)
Definition FinalizerPolicies.hpp:44
constexpr ReturnsResultOf(Action &&action) noexcept(std::is_nothrow_move_constructible_v< Action >)
Definition FinalizerPolicies.hpp:32
Definition FinalizerPolicies.hpp:61
constexpr Return finalize_call(const call::Info< Return, Args... > &call)
Definition FinalizerPolicies.hpp:70
constexpr Throws(Exception exception) noexcept(std::is_nothrow_move_constructible_v< Exception >)
Definition FinalizerPolicies.hpp:64
Determines, whether From can be explicitly converted to To.
Definition Concepts.hpp:34
Determines, whether From can be explicitly converted to To, without throwing.
Definition Concepts.hpp:43
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:197
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:169
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:146
consteval auto returns_arg() noexcept
During the finalization step, the selected call argument is returned.
Definition FinalizerPolicies.hpp:220
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:116
Definition ArgRequirementPolicies.hpp:28
Definition FinalizerPolicies.hpp:82