From 57bb43138b60a18cc3eaea181132b81c3a03a924 Mon Sep 17 00:00:00 2001 From: Denis Blank Date: Mon, 10 Dec 2018 05:08:39 +0100 Subject: [PATCH] Fix a recursive template instantiation issue on clang and gcc --- include/continuable/continuable-base.hpp | 13 +++++----- include/continuable/detail/core/base.hpp | 26 +++++++------------ .../multi/test-continuable-regression.cpp | 6 +++++ 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/include/continuable/continuable-base.hpp b/include/continuable/continuable-base.hpp index 51fb189..33b6e41 100644 --- a/include/continuable/continuable-base.hpp +++ b/include/continuable/continuable-base.hpp @@ -119,13 +119,14 @@ public: /// Constructor accepting any object convertible to the data object, /// while erasing the annotation - template >::value>* = - nullptr> - continuable_base(OData&& data) // NOLINT(misc-forwarding-reference-overload) - : data_(detail::base::proxy_continuable( - std::forward(data))) { + Data, Annotation, + detail::traits::unrefcv_t>::value>* = nullptr> + continuable_base(OtherData&& data) + : data_(detail::base::proxy_continuable< + Annotation, detail::traits::unrefcv_t>( + std::forward(data))) { } /// Constructor taking the data of other continuable_base objects diff --git a/include/continuable/detail/core/base.hpp b/include/continuable/detail/core/base.hpp index e5db7a3..74b2e3e 100644 --- a/include/continuable/detail/core/base.hpp +++ b/include/continuable/detail/core/base.hpp @@ -134,7 +134,6 @@ struct proxy_continuable, Continuation> 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 { @@ -154,7 +153,7 @@ struct attorney { util::ownership ownership) { using continuation_t = continuable_base, // traits::unrefcv_t>; - return continuation_t({std::forward(continuation)}, ownership); + return continuation_t{std::forward(continuation), ownership}; } /// Creates a continuable_base from the given continuation, @@ -165,8 +164,8 @@ struct attorney { static auto create_from(T&& continuation, Hint, util::ownership ownership) { using hint_t = traits::unrefcv_t; using proxy_t = proxy_continuable>; - return continuable_base( - proxy_t{std::forward(continuation)}, ownership); + return continuable_base{ + proxy_t{std::forward(continuation)}, ownership}; } /// Returns the ownership of the given continuable_base @@ -873,20 +872,15 @@ void finalize_continuation(Continuation&& continuation) { /// Deduces to a true type if the given callable data can be wrapped /// with the given hint and converted to the given Data. -template +template struct can_accept_continuation : std::false_type {}; template -struct can_accept_continuation< - Data, traits::identity, Continuation, - traits::void_t< - std::enable_if_t::value>, - std::enable_if_t, Continuation>, - Data>::value>>> : std::true_type - -{}; +struct can_accept_continuation, Continuation> + : traits::conjunction< + traits::is_invocable, + std::is_convertible< + proxy_continuable, Continuation>, + Data>> {}; /// Workaround for GCC bug: /// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64095 diff --git a/test/unit-test/multi/test-continuable-regression.cpp b/test/unit-test/multi/test-continuable-regression.cpp index 535bdd3..c46b0b1 100644 --- a/test/unit-test/multi/test-continuable-regression.cpp +++ b/test/unit-test/multi/test-continuable-regression.cpp @@ -43,3 +43,9 @@ TEST(regression_tests, are_multiple_args_mergeable) { tp2); EXPECT_EQ(count, 20); } + +/// Recursive instantiation issue which affects Clang and GCC +TEST(regression_tests, are_erasures_direct_chainable) { + continuable<>(make_ready_continuable()) + .then(continuable<>(make_ready_continuable())); +}