summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2017-05-25 19:04:55 +0000
committerEric Fiselier <eric@efcs.ca>2017-05-25 19:04:55 +0000
commit51056aef655e3a3c03d7e14db7e0a434c0c2ed14 (patch)
treec203c09c1bca24076a63294512d7df07b201d9a8
parent4deabc97a17a4bc3857ee027c35493c9f8e59ad8 (diff)
downloadbcm5719-llvm-51056aef655e3a3c03d7e14db7e0a434c0c2ed14.tar.gz
bcm5719-llvm-51056aef655e3a3c03d7e14db7e0a434c0c2ed14.zip
Update more coroutine_handle signatures to reflect N4663.
Thanks to Casey Carter for pointing out the out-of-date tests and implementation. llvm-svn: 303900
-rw-r--r--libcxx/include/experimental/coroutine6
-rw-r--r--libcxx/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.prom/promise.sh.cpp3
-rw-r--r--libcxx/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/destroy.sh.cpp23
-rw-r--r--libcxx/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/resume.sh.cpp43
4 files changed, 62 insertions, 13 deletions
diff --git a/libcxx/include/experimental/coroutine b/libcxx/include/experimental/coroutine
index f53aceaa3f4..f2b3e4edeaa 100644
--- a/libcxx/include/experimental/coroutine
+++ b/libcxx/include/experimental/coroutine
@@ -112,10 +112,10 @@ public:
constexpr explicit operator bool() const noexcept { return __handle_; }
_LIBCPP_ALWAYS_INLINE
- void operator()() const { resume(); }
+ void operator()() { resume(); }
_LIBCPP_ALWAYS_INLINE
- void resume() const {
+ void resume() {
_LIBCPP_ASSERT(__is_suspended(),
"resume() can only be called on suspended coroutines");
_LIBCPP_ASSERT(!done(),
@@ -124,7 +124,7 @@ public:
}
_LIBCPP_ALWAYS_INLINE
- void destroy() const {
+ void destroy() {
_LIBCPP_ASSERT(__is_suspended(),
"destroy() can only be called on suspended coroutines");
__builtin_coro_destroy(__handle_);
diff --git a/libcxx/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.prom/promise.sh.cpp b/libcxx/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.prom/promise.sh.cpp
index 597ffd6d27f..b38d7871be4 100644
--- a/libcxx/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.prom/promise.sh.cpp
+++ b/libcxx/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.prom/promise.sh.cpp
@@ -19,8 +19,7 @@
// template <class Promise>
// struct coroutine_handle<Promise>;
-// Promise& promise()
-// Promise const& promise() const
+// Promise& promise() const
#include <experimental/coroutine>
#include <type_traits>
diff --git a/libcxx/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/destroy.sh.cpp b/libcxx/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/destroy.sh.cpp
index 49899e8f703..9cc0d1d72bf 100644
--- a/libcxx/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/destroy.sh.cpp
+++ b/libcxx/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/destroy.sh.cpp
@@ -19,7 +19,7 @@
// template <class Promise = void>
// struct coroutine_handle;
-// void destroy() const
+// void destroy()
#include <experimental/coroutine>
#include <type_traits>
@@ -32,12 +32,29 @@
namespace coro = std::experimental;
+template <class H>
+auto has_destroy_imp(H&& h, int) -> decltype(h.destroy(), std::true_type{});
+template <class H>
+auto has_destroy_imp(H&&, long) -> std::false_type;
+
+template <class H>
+constexpr bool has_destroy() {
+ return decltype(has_destroy_imp(std::declval<H>(), 0))::value;
+}
+
template <class Promise>
-void do_test(coro::coroutine_handle<Promise> const& H) {
+void do_test(coro::coroutine_handle<Promise>&& H) {
+ using HType = coro::coroutine_handle<Promise>;
// FIXME Add a runtime test
{
ASSERT_SAME_TYPE(decltype(H.destroy()), void);
- ASSERT_NOT_NOEXCEPT(H.destroy());
+ LIBCPP_ASSERT_NOT_NOEXCEPT(H.destroy());
+ static_assert(has_destroy<HType&>(), "");
+ static_assert(has_destroy<HType&&>(), "");
+ }
+ {
+ static_assert(!has_destroy<HType const&>(), "");
+ static_assert(!has_destroy<HType const&&>(), "");
}
}
diff --git a/libcxx/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/resume.sh.cpp b/libcxx/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/resume.sh.cpp
index dc3beb4b7c6..b5ff187a49c 100644
--- a/libcxx/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/resume.sh.cpp
+++ b/libcxx/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/resume.sh.cpp
@@ -19,8 +19,8 @@
// template <class Promise = void>
// struct coroutine_handle;
-// void operator()() const
-// void resume() const
+// void operator()()
+// void resume()
#include <experimental/coroutine>
#include <type_traits>
@@ -33,14 +33,47 @@
namespace coro = std::experimental;
+
+template <class H>
+auto has_resume_imp(H&& h, int) -> decltype(h.resume(), std::true_type{});
+template <class H>
+auto has_resume_imp(H&&, long) -> std::false_type;
+
+template <class H>
+constexpr bool has_resume() {
+ return decltype(has_resume_imp(std::declval<H>(), 0))::value;
+}
+
+
+template <class H>
+auto has_call_operator_imp(H&& h, int) -> decltype(h(), std::true_type{});
+template <class H>
+auto has_call_operator_imp(H&&, long) -> std::false_type;
+
+template <class H>
+constexpr bool has_call_operator() {
+ return decltype(has_call_operator_imp(std::declval<H>(), 0))::value;
+}
+
template <class Promise>
-void do_test(coro::coroutine_handle<Promise> const& H) {
+void do_test(coro::coroutine_handle<Promise>&& H) {
+ using HType = coro::coroutine_handle<Promise>;
// FIXME Add a runtime test
{
ASSERT_SAME_TYPE(decltype(H.resume()), void);
ASSERT_SAME_TYPE(decltype(H()), void);
- ASSERT_NOT_NOEXCEPT(H.resume());
- ASSERT_NOT_NOEXCEPT(H());
+ LIBCPP_ASSERT_NOT_NOEXCEPT(H.resume());
+ LIBCPP_ASSERT_NOT_NOEXCEPT(H());
+ static_assert(has_resume<HType&>(), "");
+ static_assert(has_resume<HType&&>(), "");
+ static_assert(has_call_operator<HType&>(), "");
+ static_assert(has_call_operator<HType&&>(), "");
+ }
+ {
+ static_assert(!has_resume<HType const&>(), "");
+ static_assert(!has_resume<HType const&&>(), "");
+ static_assert(!has_call_operator<HType const&>(), "");
+ static_assert(!has_call_operator<HType const&&>(), "");
}
}
OpenPOWER on IntegriCloud