mirror of
https://github.com/Naios/continuable.git
synced 2026-11-09 22:59:58 +08:00
First conversion into if constexpr
This commit is contained in:
parent
14ebb40756
commit
0da0dca385
@ -198,20 +198,25 @@ constexpr auto unbox_continuables(Args&&... args) {
|
|||||||
std::forward<Args>(args)...);
|
std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
template <typename Callback, typename Data>
|
template <typename Callback, typename Data>
|
||||||
constexpr auto finalize_impl(traits::identity<void>, Callback&& callback,
|
constexpr auto finalize_data(Callback&& callback, Data&& data) {
|
||||||
Data&&) {
|
using result_t = decltype(unbox_continuables(std::forward<Data>(data)));
|
||||||
return std::forward<Callback>(callback)();
|
|
||||||
}
|
// Guard the final result against void
|
||||||
template <typename... Args, typename Callback, typename Data>
|
return CONTINUABLE_IF_CONSTEXPR(
|
||||||
constexpr auto finalize_impl(traits::identity<std::tuple<Args...>>,
|
std::is_void<result_t>::value,
|
||||||
Callback&& callback, Data&& data) {
|
{
|
||||||
// Call the final callback with the cleaned result
|
// Just invoke the callback with zero arguments
|
||||||
return traits::unpack(unbox_continuables(std::forward<Data>(data)),
|
return std::forward<Callback>(callback)();
|
||||||
std::forward<Callback>(callback));
|
},
|
||||||
|
{
|
||||||
|
// Call the final callback with the cleaned result
|
||||||
|
return traits::unpack(unbox_continuables(std::forward<Data>(data)),
|
||||||
|
std::forward<Callback>(callback));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace detail {
|
||||||
struct hint_mapper {
|
struct hint_mapper {
|
||||||
template <typename... T>
|
template <typename... T>
|
||||||
constexpr auto operator()(T...) -> hints::signature_hint_tag<T...> {
|
constexpr auto operator()(T...) -> hints::signature_hint_tag<T...> {
|
||||||
@ -220,15 +225,6 @@ struct hint_mapper {
|
|||||||
};
|
};
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
template <typename Callback, typename Data>
|
|
||||||
constexpr auto finalize_data(Callback&& callback, Data&& data) {
|
|
||||||
using result_t = decltype(unbox_continuables(std::forward<Data>(data)));
|
|
||||||
// Guard the final result against void
|
|
||||||
return detail::finalize_impl(traits::identity<std::decay_t<result_t>>{},
|
|
||||||
std::forward<Callback>(callback),
|
|
||||||
std::forward<Data>(data));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
constexpr auto hint_of_data() {
|
constexpr auto hint_of_data() {
|
||||||
return decltype(finalize_data(detail::hint_mapper{}, std::declval<Data>())){};
|
return decltype(finalize_data(detail::hint_mapper{}, std::declval<Data>())){};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user