Fix the simplification

This commit is contained in:
Denis Blank 2018-03-02 02:51:53 +01:00
parent 92ba25cd23
commit 83752502dc
3 changed files with 12 additions and 15 deletions

View File

@ -109,7 +109,7 @@ class result_submitter
std::atomic_thread_fence(std::memory_order_acquire);
// Call the final callback with the cleaned result
std::call_once(flag_, [&](auto&&... args) {
std::call_once(flag_, [&] {
remapping::finalize_data(std::move(callback_), std::move(result_));
});
}
@ -169,7 +169,7 @@ public:
}
constexpr auto& head() noexcept {
return &result_;
return result_;
}
};

View File

@ -54,7 +54,6 @@ namespace composition {
/// - single async value -> single value
/// - multiple async value -> tuple of async values.
namespace remapping {
// Guard object for representing void results
template <typename Continuable>
class continuable_box;
template <typename Data>
@ -158,7 +157,7 @@ struct continuable_box_unpacker {
typename T,
std::enable_if_t<is_continuable_box<std::decay_t<T>>::value>* = nullptr>
auto operator()(T&& box) {
return std::forward<T>(box).unpack();
return std::forward<T>(box).unbox();
}
};
} // namespace detail
@ -181,12 +180,13 @@ constexpr auto unbox_continuables(Args&&... args) {
}
namespace detail {
template <typename T, typename Callback, typename Data>
template <typename Callback, typename Data>
void finalize_impl(traits::identity<void>, Callback&& callback, Data&&) {
std::forward<Callback>(callback)();
}
template <typename T, typename Callback, typename Data>
void finalize_impl(traits::identity<T>, Callback&& callback, Data&& data) {
template <typename... Args, typename Callback, typename Data>
void finalize_impl(traits::identity<std::tuple<Args...>>, Callback&& callback,
Data&& data) {
// Call the final callback with the cleaned result
traits::unpack(unbox_continuables(std::forward<Data>(data)),
std::forward<Callback>(callback));
@ -195,14 +195,11 @@ void finalize_impl(traits::identity<T>, Callback&& callback, Data&& data) {
template <typename Callback, typename Data>
void finalize_data(Callback&& callback, Data&& data) {
using result_t =
decltype(traits::unpack(unbox_continuables(std::forward<Data>(data)),
std::forward<Callback>(callback)));
using result_t = decltype(unbox_continuables(std::forward<Data>(data)));
// Guard the final result against void
return detail::finalize_impl(traits::identity<result_t>{},
std::forward<Data>(data),
std::forward<Callback>(callback));
return detail::finalize_impl(traits::identity<std::decay_t<result_t>>{},
std::forward<Callback>(callback),
std::forward<Data>(data));
}
} // namespace remapping
} // namespace composition

View File

@ -101,7 +101,7 @@ public:
template <typename Box, typename N>
void operator()(async_traverse_detach_tag, Box&& box, N&& next) {
box->fetch()
box.fetch()
.then([ box = std::addressof(box),
next = std::forward<N>(next) ](auto&&... args) mutable {