diff --git a/include/continuable/detail/traverse-async.hpp b/include/continuable/detail/traverse-async.hpp index 456251e..987e3c6 100644 --- a/include/continuable/detail/traverse-async.hpp +++ b/include/continuable/detail/traverse-async.hpp @@ -41,6 +41,7 @@ #include #include +#include namespace cti { namespace detail { @@ -66,13 +67,16 @@ struct async_traverse_in_place_tag {}; template struct relocate_index_pack; template -struct relocate_index_pack> - : std::common_type> {}; +struct relocate_index_pack> + : std::common_type< + std::integer_sequence> {}; /// Creates a sequence from begin to end explicitly template -using explicit_range_sequence_of_t = typename relocate_index_pack< - Begin, typename make_index_pack::type>::type; +using explicit_range_sequence_of_t = + typename relocate_index_pack>::type; /// Continues the traversal when the object is called template @@ -104,7 +108,7 @@ auto make_resume_traversal_callable(Frame&& frame, State&& state) /// Stores the visitor and the arguments to traverse template class async_traversal_frame : public Visitor { - tuple args_; + std::tuple args_; #ifndef _NDEBUG std::atomic finished_; @@ -120,7 +124,7 @@ class async_traversal_frame : public Visitor { public: explicit async_traversal_frame(Visitor visitor, Args... args) - : Visitor(std::move(visitor)), args_(util::make_tuple(std::move(args)...)) + : Visitor(std::move(visitor)), args_(std::make_tuple(std::move(args)...)) #ifndef _NDEBUG , finished_(false) @@ -137,21 +141,19 @@ public: explicit async_traversal_frame(async_traverse_in_place_tag, MapperArg&& mapper_arg, Args... args) : Visitor(std::forward(mapper_arg)), - args_(util::make_tuple(std::move(args)...)), finished_(false) { + args_(std::make_tuple(std::move(args)...)), finished_(false) { } /// Returns the arguments of the frame - tuple& head() noexcept { + std::tuple& head() noexcept { return args_; } /// Calls the visitor with the given element template - auto traverse(T&& value) -> decltype(util::invoke(std::declval(), - async_traverse_visit_tag{}, - std::forward(value))) { - return util::invoke(visitor(), async_traverse_visit_tag{}, - std::forward(value)); + auto traverse(T&& value) -> decltype(visitor()(async_traverse_visit_tag{}, + std::forward(value))) { + return visitor()(async_traverse_visit_tag{}, std::forward(value)); } /// Calls the visitor with the given element and a continuation @@ -169,8 +171,8 @@ public: // Invoke the visitor with the current value and the // callable object to resume the control flow. - util::invoke(visitor(), async_traverse_detach_tag{}, std::forward(value), - std::move(resumable)); + visitor()(async_traverse_detach_tag{}, std::forward(value), + std::move(resumable)); } /// Calls the visitor with no arguments to signalize that the @@ -209,8 +211,8 @@ struct static_async_range { } constexpr auto operator*() const noexcept - -> decltype(util::get(*target_)) { - return util::get(*target_); + -> decltype(std::get(*target_)) { + return std::get(*target_); } template @@ -340,7 +342,7 @@ public: /// Async traverse a single element, and do nothing. /// This function is matched last. template - void async_traverse_one_impl(Matcher, Current&& current) { + void async_traverse_one_impl(Matcher, Current&& /*current*/) { // Do nothing if the visitor doesn't accept the type } @@ -352,13 +354,12 @@ public: Current&& current) /// SFINAE this out if the visitor doesn't accept /// the given element - -> typename always_void< - decltype(std::declval()->traverse(*current))>::type { + -> traits::void_t()->traverse(*current))> { if (!frame_->traverse(*current)) { // Store the current call hierarchy into a tuple for // later re-entrance. auto hierarchy = - std::tuple_cat(util::make_tuple(current.next()), hierarchy_); + std::tuple_cat(std::make_tuple(current.next()), hierarchy_); // First detach the current execution context detach(); @@ -406,8 +407,8 @@ public: } template - void async_traverse_static_async_range(pack_c, - Current&& current) { + void async_traverse_static_async_range( + std::integer_sequence, Current&& current) { int dummy[] = {0, ((void)async_traverse_one_checked( current.template relocate()), 0)...}; @@ -484,7 +485,7 @@ struct resume_state_callable { // Don't forward the arguments here, since we still need // the objects in a valid state later. traversal_point_of_t point( - frame, util::make_tuple(parent, hierarchy...), detached); + frame, std::make_tuple(parent, hierarchy...), detached); point.async_traverse(std::forward(current)); @@ -505,7 +506,7 @@ struct resume_state_callable { template void resume_traversal_callable::operator()() { auto hierarchy = std::tuple_cat(std::make_tuple(frame_), state_); - util::invoke_fused(resume_state_callable{}, std::move(hierarchy)); + traits::unpack(std::move(hierarchy), resume_state_callable{}); } /// Gives access to types related to the traversal frame