6#ifndef MIMICPP_EXPECTATION_POLICIES_FINALIZER_POLICIES_HPP
7#define MIMICPP_EXPECTATION_POLICIES_FINALIZER_POLICIES_HPP
17#ifndef MIMICPP_DETAIL_IS_MODULE
20 #include <type_traits>
26 template <
typename Action>
27 requires std::same_as<Action, std::remove_cvref_t<Action>>
28 && std::is_move_constructible_v<Action>
34 noexcept(std::is_nothrow_move_constructible_v<Action>)
35 : m_Action{std::move(action)}
39 template <
typename Return,
typename... Args>
40 requires std::invocable<Action&,
call::Info<Return, Args...>
const&>
42 std::invoke_result_t<Action&,
call::Info<Return, Args...>
const&>,
47 std::is_nothrow_invocable_v<Action&,
call::Info<Return, Args...>
const&>
50 return static_cast<Return
>(
51 std::invoke(m_Action,
call));
58 template <
typename Exception>
59 requires(!std::is_reference_v<Exception>)
60 && std::copyable<Exception>
65 explicit constexpr Throws(Exception exception)
noexcept(std::is_nothrow_move_constructible_v<Exception>)
66 : m_Exception{std::move(exception)}
70 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]]
auto const&
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]]
auto const&
call)
mutable noexcept ->
auto& {
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 = expectation::policies::detail::args_selector_fn<
173 std::add_lvalue_reference_t,
174 std::index_sequence<index, otherIndices...>>;
175 using apply_strategy_t = expectation::policies::detail::arg_list_forward_apply_fn;
179 expectation::policies::detail::apply_args_fn{arg_selector_t{}, apply_strategy_t{}},
180 std::forward<Action>(action))};
193 template <
typename Action>
196 noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<Action>, Action>)
198 using arg_selector_t = expectation::policies::detail::all_args_selector_fn<std::add_lvalue_reference_t>;
199 using apply_strategy_t = expectation::policies::detail::arg_list_forward_apply_fn;
203 expectation::policies::detail::apply_args_fn{arg_selector_t{}, apply_strategy_t{}},
204 std::forward<Action>(action))};
214 template <std::
size_t index>
218 using arg_selector_t = expectation::policies::detail::args_selector_fn<
219 std::add_rvalue_reference_t,
220 std::index_sequence<index>>;
221 using apply_strategy_t = expectation::policies::detail::arg_list_forward_apply_fn;
225 expectation::policies::detail::apply_args_fn{arg_selector_t{}, apply_strategy_t{}},
238 template <
typename T>
239 requires std::copyable<std::remove_cvref_t<T>>
242 T && exception)
noexcept(std::is_nothrow_constructible_v<std::remove_cvref_t<T>, T>)
245 std::forward<T>(exception)};
#define MIMICPP_DETAIL_MODULE_EXPORT
Definition Config.hpp:19
Definition FinalizerPolicies.hpp:30
constexpr ReturnsResultOf(Action &&action) noexcept(std::is_nothrow_move_constructible_v< Action >)
Definition FinalizerPolicies.hpp:33
constexpr Return finalize_call(call::Info< Return, Args... > const &call) noexcept(std::is_nothrow_invocable_v< Action &, call::Info< Return, Args... > const & > &&util::nothrow_explicitly_convertible_to< std::invoke_result_t< Action &, call::Info< Return, Args... > const & >, Return >)
Definition FinalizerPolicies.hpp:45
Definition FinalizerPolicies.hpp:62
constexpr Return finalize_call(call::Info< Return, Args... > const &)
Definition FinalizerPolicies.hpp:71
constexpr Throws(Exception exception) noexcept(std::is_nothrow_move_constructible_v< Exception >)
Definition FinalizerPolicies.hpp:65
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:195
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:216
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 ArgumentList.hpp:24
Definition FinalizerPolicies.hpp:82
constexpr T & unwrap_ref(std::reference_wrapper< T > const ref) noexcept
Unwraps the given std::reference_wrapper and returns the referenced object.
Definition UnwrapRef.hpp:29