7#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_FUNCTIONAL_PERFECT_FORWARD_CALL_WRAPPER_HPP_
8#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_FUNCTIONAL_PERFECT_FORWARD_CALL_WRAPPER_HPP_
15#include "arene/base/stdlib_choice/enable_if.hpp"
16#include "arene/base/stdlib_choice/forward.hpp"
17#include "arene/base/stdlib_choice/is_constructible.hpp"
18#include "arene/base/stdlib_choice/move.hpp"
19#include "arene/base/stdlib_choice/tuple.hpp"
31namespace functional_detail {
39struct bound_args_tag {};
70template <
typename Policy,
typename Func,
typename... BoundArgs>
71class perfect_forward_call_wrapper
72 : ebo_holder<invoke_tag<perfect_forward_call_wrapper<Policy, Func, BoundArgs...>>, Func>
73 , ebo_holder<bound_args_tag<perfect_forward_call_wrapper<Policy, Func, BoundArgs...>>, std::tuple<BoundArgs...>> {
75 using bound_arg_tuple = std::tuple<BoundArgs...>;
94 invoke_tag<perfect_forward_call_wrapper>{}
102 template <
class Self>
103 static constexpr auto bound_args(Self&& self)
noexcept ->
give_cvref_to_t<Self&&, std::tuple<BoundArgs...>> {
105 bound_args_tag<perfect_forward_call_wrapper>{}
115 constexpr perfect_forward_call_wrapper(perfect_forward_call_wrapper
const&
copy) =
default;
117 constexpr perfect_forward_call_wrapper(perfect_forward_call_wrapper&&
move) =
default;
119 constexpr auto operator=(perfect_forward_call_wrapper
const&
copy) -> perfect_forward_call_wrapper& =
default;
121 constexpr auto operator=(perfect_forward_call_wrapper&&
move) -> perfect_forward_call_wrapper& =
default;
132 typename... ArgsToBind,
135 std::enable_if_t<std::is_constructible<Func, BoundFunc&&>::value>,
136 std::enable_if_t<std::is_constructible<std::tuple<BoundArgs...>, ArgsToBind&&...>::value>> =
nullptr>
137 constexpr explicit perfect_forward_call_wrapper(BoundFunc&& func_to_bind, ArgsToBind&&... args_to_bind)
noexcept(
139 std::is_nothrow_constructible<std::tuple<BoundArgs...>, ArgsToBind&&...>::value
141 : invocable_wrapper{std::
forward<BoundFunc>(func_to_bind)},
142 bound_args_wrapper{std::
forward<ArgsToBind>(args_to_bind)...} {
143 static_assert(
sizeof...(ArgsToBind) ==
sizeof...(BoundArgs),
"Must store all bound arguments");
147 ~perfect_forward_call_wrapper() =
default;
155 typename... CallArgsT,
157 constexpr auto operator()(CallArgsT&&... call_args) &
noexcept(
175 typename... CallArgsT,
177 constexpr auto operator()(CallArgsT&&... call_args) & =
delete;
186 typename... CallArgsT,
189 constexpr auto operator()(CallArgsT&&... call_args)
const&
noexcept(
207 typename... CallArgsT,
210 constexpr auto operator()(CallArgsT&&... call_args)
const& =
delete;
219 typename... CallArgsT,
221 constexpr auto operator()(CallArgsT&&... call_args) &&
noexcept(
239 typename... CallArgsT,
241 constexpr auto operator()(CallArgsT&&... call_args) && =
delete;
250 typename... CallArgsT,
253 constexpr auto operator()(CallArgsT&&... call_args)
const&&
noexcept(
273 typename... CallArgsT,
276 constexpr auto operator()(CallArgsT&&... call_args)
const&& =
delete;
constexpr ebo_holder() noexcept(std::is_nothrow_default_constructible< T >::value)
Definition ebo_holder.hpp:57
constexpr auto get_value(invoke_tag< perfect_forward_call_wrapper< Policy, Func, BoundArgs... > >) const &noexcept -> value_type const &
Definition ebo_holder.hpp:89
static constexpr value_type value
Definition integral_constant.hpp:34
Provides the decays_to_v<T, U> trait.
Definition accumulate.hpp:37
constexpr auto move(InIterator first, InIterator last, OutIterator output) noexcept(noexcept(*first++) &&noexcept(output++) &&//CODEQLFP(EXP52-CPP) CODEQLFP(A5-2-6) noexcept(first !=last) &&//CODEQLFP(A5-2-6) std::is_nothrow_assignable<, typename std::iterator_traits< InIterator >::value_type >::value) -> OutIterator
Moves the elements in the range [first, last), to another range beginning at output,...
Definition move.hpp:46
constexpr bool is_invocable_v
Determine if a functor type is invocable with the specified argument types.
constexpr auto copy(InputIterator first, InputIterator last, OutputIterator output) noexcept(noexcept(*(++output)) &&noexcept(*(++first)) &&noexcept(first !=last) &&std::is_nothrow_assignable<, typename std::iterator_traits< InputIterator >::reference >::value) -> OutputIterator
Copies the elements in the range, defined by [first, last), to another range beginning at output.
Definition copy.hpp:40
give_cvref_to_detail::give_reference_to< From, give_cv_to_t< std::remove_reference_t< From >, To > > give_cvref_to_t
Add the cv-ref qualification from one type to another.
Definition give_cvref_to.hpp:45
typename invoke_result< Fn, Args... >::type invoke_result_t
The return type of a functor invoked with the specified arguments.
Definition is_invocable.hpp:271
constexpr bool is_nothrow_invocable_v
Determine if a functor type is no-throw invocable with the specified argument types.
typename constraints_impl::constraints< EnableIfs... >::type constraints
Helper used to express template constraints in a consistent way using std::enable_if_t.
Definition constraints.hpp:51
Definition accumulate.hpp:36
constexpr auto move(T &&value) noexcept -> remove_reference_t< T > &&
Cast a value to an rvalue.
Definition move.hpp:30
typename enable_if< Condition, Type >::type enable_if_t
Type alias to support constraining templates. Is an alias for the specified type if the Condition is ...
Definition enable_if.hpp:41
constexpr auto forward(remove_reference_t< T > &value) noexcept -> T &&
Cast a value to an rvalue if T is an rvalue or rvalue reference, otherwise forward an lvalue referenc...
Definition forward.hpp:24