From 83752502dc93f6086e08863ce96ba414a2419d80 Mon Sep 17 00:00:00 2001 From: Denis Blank Date: Fri, 2 Mar 2018 02:51:53 +0100 Subject: [PATCH] Fix the simplification --- .../continuable/detail/composition-all.hpp | 4 ++-- .../detail/composition-remapping.hpp | 21 ++++++++----------- .../continuable/detail/composition-seq.hpp | 2 +- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/include/continuable/detail/composition-all.hpp b/include/continuable/detail/composition-all.hpp index cae3c64..2dc0333 100644 --- a/include/continuable/detail/composition-all.hpp +++ b/include/continuable/detail/composition-all.hpp @@ -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_; } }; diff --git a/include/continuable/detail/composition-remapping.hpp b/include/continuable/detail/composition-remapping.hpp index 2c476fe..3ac5eb6 100644 --- a/include/continuable/detail/composition-remapping.hpp +++ b/include/continuable/detail/composition-remapping.hpp @@ -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 class continuable_box; template @@ -158,7 +157,7 @@ struct continuable_box_unpacker { typename T, std::enable_if_t>::value>* = nullptr> auto operator()(T&& box) { - return std::forward(box).unpack(); + return std::forward(box).unbox(); } }; } // namespace detail @@ -181,12 +180,13 @@ constexpr auto unbox_continuables(Args&&... args) { } namespace detail { -template +template void finalize_impl(traits::identity, Callback&& callback, Data&&) { std::forward(callback)(); } -template -void finalize_impl(traits::identity, Callback&& callback, Data&& data) { +template +void finalize_impl(traits::identity>, Callback&& callback, + Data&& data) { // Call the final callback with the cleaned result traits::unpack(unbox_continuables(std::forward(data)), std::forward(callback)); @@ -195,14 +195,11 @@ void finalize_impl(traits::identity, Callback&& callback, Data&& data) { template void finalize_data(Callback&& callback, Data&& data) { - using result_t = - decltype(traits::unpack(unbox_continuables(std::forward(data)), - std::forward(callback))); - + using result_t = decltype(unbox_continuables(std::forward(data))); // Guard the final result against void - return detail::finalize_impl(traits::identity{}, - std::forward(data), - std::forward(callback)); + return detail::finalize_impl(traits::identity>{}, + std::forward(callback), + std::forward(data)); } } // namespace remapping } // namespace composition diff --git a/include/continuable/detail/composition-seq.hpp b/include/continuable/detail/composition-seq.hpp index fbe64b1..522673d 100644 --- a/include/continuable/detail/composition-seq.hpp +++ b/include/continuable/detail/composition-seq.hpp @@ -101,7 +101,7 @@ public: template void operator()(async_traverse_detach_tag, Box&& box, N&& next) { - box->fetch() + box.fetch() .then([ box = std::addressof(box), next = std::forward(next) ](auto&&... args) mutable {