1 // -*- C++ -*- 2 //===----------------------------------------------------------------------===// 3 // 4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5 // See https://llvm.org/LICENSE.txt for license information. 6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 // 8 //===----------------------------------------------------------------------===// 9 10 // UNSUPPORTED: c++03, c++11 11 12 // <experimental/coroutine> 13 14 // template <class Promise = void> 15 // struct coroutine_handle; 16 17 // coroutine_handle& operator=(nullptr_t) noexcept 18 19 #include <experimental/coroutine> 20 #include <type_traits> 21 #include <cassert> 22 23 #include "test_macros.h" 24 25 namespace coro = std::experimental; 26 27 template <class C> do_test()28void do_test() { 29 int dummy = 42; 30 void* dummy_h = &dummy; 31 { 32 C c; ((void)c); 33 static_assert(std::is_nothrow_assignable<C&, std::nullptr_t>::value, ""); 34 static_assert(!std::is_assignable<C&, void*>::value, ""); 35 } 36 { 37 C c = C::from_address(dummy_h); 38 assert(c.address() == &dummy); 39 c = nullptr; 40 assert(c.address() == nullptr); 41 c = nullptr; 42 assert(c.address() == nullptr); 43 } 44 { 45 C c; 46 C& cr = (c = nullptr); 47 assert(&c == &cr); 48 } 49 } 50 main(int,char **)51int main(int, char**) 52 { 53 do_test<coro::coroutine_handle<>>(); 54 do_test<coro::coroutine_handle<int>>(); 55 56 return 0; 57 } 58