Provide the get_arg_t and is_ready_arg_t also from continuables created through make_*

This commit is contained in:
Denis Blank 2018-12-08 04:49:03 +01:00
parent 6947091a27
commit 24158583b7
3 changed files with 41 additions and 12 deletions

View File

@ -811,10 +811,14 @@ constexpr auto make_continuable(Continuation&& continuation) {
"use make_continuable<void>(...). Continuables with an exact "
"signature may be created through make_continuable<Args...>.");
// TODO
using hint_t = detail::traits::identity<Args...>;
using continuation_t =
detail::base::proxy_continuable<hint_t,
detail::traits::unrefcv_t<Continuation>>;
return detail::base::attorney::create_from(
std::forward<Continuation>(continuation),
detail::hints::from_explicit(detail::traits::identity<Args...>{}),
continuation_t{std::forward<Continuation>(continuation)},
typename detail::hints::from_explicit<hint_t>::type{},
detail::util::ownership{});
}

View File

@ -56,16 +56,14 @@ namespace hints {
/// from an argument pack as specified by make_continuable.
///
/// This is the overload taking an arbitrary amount of args
template <typename Hint>
struct from_explicit;
template <typename... HintArgs>
constexpr auto from_explicit(traits::identity<HintArgs...> hint) {
return hint;
}
/// \copybrief from_explicit
///
/// This is the overload taking a void arg.
constexpr auto from_explicit(traits::identity<void> /*hint*/) {
return traits::identity<>{};
}
struct from_explicit<traits::identity<HintArgs...>>
: std::common_type<traits::identity<HintArgs...>> {};
template <>
struct from_explicit<traits::identity<void>>
: std::common_type<traits::identity<>> {};
} // namespace hints
} // namespace detail
} // namespace cti

View File

@ -119,6 +119,33 @@ struct ready_continuation<> {
}
};
template <typename Hint, typename Continuation>
struct proxy_continuable;
template <typename... Args, typename Continuation>
struct proxy_continuable<traits::identity<Args...>, Continuation>
: Continuation {
explicit proxy_continuable(Continuation continuation)
: Continuation(std::move(continuation)) {
}
~proxy_continuable() = default;
proxy_continuable(proxy_continuable&&) = default;
proxy_continuable(proxy_continuable const&) = delete;
proxy_continuable& operator=(proxy_continuable&&) = default;
proxy_continuable& operator=(proxy_continuable const&) = delete;
using Continuation::Continuation;
using Continuation::operator();
bool operator()(is_ready_arg_t) const noexcept {
return false;
}
std::tuple<Args...> operator()(get_arg_t) && {
util::unreachable();
}
};
struct attorney {
/// Creates a continuable_base from the given continuation, annotation
/// and ownership.