diff --git a/include/Continuable.h b/include/Continuable.h index 83d4113..3164b16 100644 --- a/include/Continuable.h +++ b/include/Continuable.h @@ -192,8 +192,12 @@ public: /// Waits for this continuable and invokes the given callback. template auto then(_CTy&& functional) - -> typename std::enable_if::type>::value, - typename detail::unary_chainer_t<_CTy>::result_t>::type + -> typename std::enable_if< + !detail::is_continuable< + typename std::decay<_CTy>::type + >::value, + typename detail::unary_chainer_t<_CTy>::result_t + >::type { // Transfer the insert function to the local scope. // Also use it as an r-value reference to try to get move semantics with c++11 lambdas. @@ -215,8 +219,12 @@ public: /// Waits for this continuable and continues with the given one. template auto then(_CTy&& continuable) - -> typename std::enable_if::type>::value, - typename std::decay<_CTy>::type>::type + -> typename std::enable_if< + detail::is_continuable< + typename std::decay<_CTy>::type + >::value, + typename std::decay<_CTy>::type + >::type { static_assert(std::is_rvalue_reference<_CTy&&>::value, "Given continuable must be passed as r-value!"); @@ -371,6 +379,9 @@ namespace detail >::wrap(std::forward<_CTy>(functional)); return detail::functional_corrector<_CTy>::correct(std::forward<_CTy>(functional)); } + */ + + /* /// Route continuable returning functionals through. template @@ -389,8 +400,14 @@ namespace detail /// Wrap continuables into the continuable returning functional type. template static auto box_continuable_trait(_CTy&& continuable) - -> typename std::enable_if::type>::value, - std::function::type(_ATy...)>>::type + -> typename std::enable_if< + detail::is_continuable< + typename std::decay<_CTy>::type + >::value, + std::function< + typename std::decay<_CTy>::type(_ATy...) + > + >::type { // Trick C++11 lambda capture rules for non copyable but moveable continuables. std::shared_ptr::type> shared_continuable = @@ -406,8 +423,12 @@ namespace detail /// Route functionals through and forward to remove_void_trait template static auto box_continuable_trait(_CTy&& continuable) - -> typename std::enable_if::type>::value, - typename std::decay<_CTy>::type>::type + -> typename std::enable_if< + !detail::is_continuable< + typename std::decay<_CTy>::type + >::value, + typename std::decay<_CTy>::type + >::type { return continuable; }