Author: ericwf Date: Thu May 25 14:04:55 2017 New Revision: 303900 URL: http://llvm.org/viewvc/llvm-project?rev=303900&view=rev Log: Update more coroutine_handle signatures to reflect N4663.
Thanks to Casey Carter for pointing out the out-of-date tests and implementation. Modified: libcxx/trunk/include/experimental/coroutine libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.prom/promise.sh.cpp libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/destroy.sh.cpp libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/resume.sh.cpp Modified: libcxx/trunk/include/experimental/coroutine URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/coroutine?rev=303900&r1=303899&r2=303900&view=diff ============================================================================== --- libcxx/trunk/include/experimental/coroutine (original) +++ libcxx/trunk/include/experimental/coroutine Thu May 25 14:04:55 2017 @@ -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_); Modified: libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.prom/promise.sh.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.prom/promise.sh.cpp?rev=303900&r1=303899&r2=303900&view=diff ============================================================================== --- libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.prom/promise.sh.cpp (original) +++ libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.prom/promise.sh.cpp Thu May 25 14:04:55 2017 @@ -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> Modified: libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/destroy.sh.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/destroy.sh.cpp?rev=303900&r1=303899&r2=303900&view=diff ============================================================================== --- libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/destroy.sh.cpp (original) +++ libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/destroy.sh.cpp Thu May 25 14:04:55 2017 @@ -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&&>(), ""); } } Modified: libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/resume.sh.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/resume.sh.cpp?rev=303900&r1=303899&r2=303900&view=diff ============================================================================== --- libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/resume.sh.cpp (original) +++ libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.resumption/resume.sh.cpp Thu May 25 14:04:55 2017 @@ -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&&>(), ""); } } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits