diff options
author | Gor Nishanov <GorNishanov@gmail.com> | 2018-04-04 22:18:03 +0000 |
---|---|---|
committer | Gor Nishanov <GorNishanov@gmail.com> | 2018-04-04 22:18:03 +0000 |
commit | 0f87a807950704b080dab6ec3cf06ff77eaf3cb0 (patch) | |
tree | 67f765b16dda355b73511c2742d11cda1c050031 /libcxx/test | |
parent | f11eb3ebe77729426e562d7d4d7ebb1d5ff2e7c8 (diff) | |
download | bcm5719-llvm-0f87a807950704b080dab6ec3cf06ff77eaf3cb0.tar.gz bcm5719-llvm-0f87a807950704b080dab6ec3cf06ff77eaf3cb0.zip |
[coroutines] Add noop_coroutine to <experimental/coroutine>
A recent addition to Coroutines TS (https://wg21.link/p0913) adds a pre-defined
coroutine noop_coroutine that does nothing.
This patch implements require library types in <experimental/coroutine>
Related clang and llvm patches:
https://reviews.llvm.org/D45114
https://reviews.llvm.org/D45120
llvm-svn: 329237
Diffstat (limited to 'libcxx/test')
-rw-r--r-- | libcxx/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.noop/noop_coroutine.pass.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/libcxx/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.noop/noop_coroutine.pass.cpp b/libcxx/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.noop/noop_coroutine.pass.cpp new file mode 100644 index 00000000000..4ff9414dfdf --- /dev/null +++ b/libcxx/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.noop/noop_coroutine.pass.cpp @@ -0,0 +1,66 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 +// XFAIL: clang-5, clang-6 +// <experimental/coroutine> +// struct noop_coroutine_promise; +// using noop_coroutine_handle = coroutine_handle<noop_coroutine_promise>; +// noop_coroutine_handle noop_coroutine() noexcept; + +#include <experimental/coroutine> +#include <cassert> +#include <type_traits> + +namespace coro = std::experimental::coroutines_v1; + +static_assert(std::is_same<coro::coroutine_handle<coro::noop_coroutine_promise>, coro::noop_coroutine_handle>::value, ""); +static_assert(std::is_same<decltype(coro::noop_coroutine()), coro::noop_coroutine_handle>::value, ""); + +// template <> struct coroutine_handle<noop_coroutine_promise> : coroutine_handle<> +// { +// // 18.11.2.7 noop observers +// constexpr explicit operator bool() const noexcept; +// constexpr bool done() const noexcept; + +// // 18.11.2.8 noop resumption +// constexpr void operator()() const noexcept; +// constexpr void resume() const noexcept; +// constexpr void destroy() const noexcept; + +// // 18.11.2.9 noop promise access +// noop_coroutine_promise& promise() const noexcept; + +// // 18.11.2.10 noop address +// constexpr void* address() const noexcept; + +int main() +{ + auto h = coro::noop_coroutine(); + coro::coroutine_handle<> base = h; + + assert(h); + assert(base); + + assert(!h.done()); + assert(!base.done()); + + h.resume(); + h.destroy(); + h(); + static_assert(h.done() == false, ""); + static_assert(h, ""); + + h.promise(); + assert(h.address() == base.address()); + assert(h.address() != nullptr); + assert(coro::coroutine_handle<>::from_address(h.address()) == base); +} + |