From a3e995c0ce9a3fb447d78ad4ab3aeb6b83483607 Mon Sep 17 00:00:00 2001 From: Denis Blank Date: Mon, 12 Mar 2018 07:24:04 +0100 Subject: [PATCH] Improve order dependence for the coroutine detection --- include/continuable/continuable-base.hpp | 6 +++- include/continuable/detail/awaiting.hpp | 36 ++++--------------- .../multi/test-continuable-await.cpp | 5 +-- 3 files changed, 15 insertions(+), 32 deletions(-) diff --git a/include/continuable/continuable-base.hpp b/include/continuable/continuable-base.hpp index f270547..7b7cba5 100644 --- a/include/continuable/continuable-base.hpp +++ b/include/continuable/continuable-base.hpp @@ -36,7 +36,6 @@ #include #include -#include #include #include #include @@ -45,6 +44,11 @@ #include #include #include +#include + +#ifdef CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE +#include +#endif // CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE namespace cti { /// \defgroup Base Base diff --git a/include/continuable/detail/awaiting.hpp b/include/continuable/detail/awaiting.hpp index 6c4a922..683dc64 100644 --- a/include/continuable/detail/awaiting.hpp +++ b/include/continuable/detail/awaiting.hpp @@ -28,16 +28,13 @@ SOFTWARE. **/ +// Exclude this header when coroutines are not available #ifndef CONTINUABLE_DETAIL_AWAITING_HPP_INCLUDED #define CONTINUABLE_DETAIL_AWAITING_HPP_INCLUDED -// Exlude this header when coroutines are not available -#ifdef CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE - #include #include -#include #include #include #include @@ -133,32 +130,13 @@ template struct coroutine_traits< cti::continuable_base>, - FunctionArgs...> /*{ - struct promise_type { - // boost::promise p; - auto get_return_object() { - // return p.get_future(); - } - suspend_always initial_suspend() { - return {}; - } - suspend_never final_suspend() { - return {}; - } - void set_exception(std::exception_ptr e) { - // p.set_exception(std::move(e)); - } - void unhandled_exception() { - // p.set_exception(std::current_exception()); - } - template - void return_value(U&& u) { - // p.set_value(std::forward(u)); - } - }; -}*/; + FunctionArgs...> { + + static_assert(cti::detail::traits::fail::value, + "Using a continuable as return value from co_return " + "expressions isn't supported yet!"); +}; } // namespace experimental } // namespace std -#endif // CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE #endif // CONTINUABLE_DETAIL_UTIL_HPP_INCLUDED diff --git a/test/unit-test/multi/test-continuable-await.cpp b/test/unit-test/multi/test-continuable-await.cpp index f435f60..8bef212 100644 --- a/test/unit-test/multi/test-continuable-await.cpp +++ b/test/unit-test/multi/test-continuable-await.cpp @@ -21,6 +21,9 @@ SOFTWARE. **/ +#include + +#include #ifdef CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE #ifndef CONTINUABLE_WITH_NO_EXCEPTIONS @@ -29,8 +32,6 @@ #include -#include - namespace std { namespace experimental { template