1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // UNSUPPORTED: libcpp-has-no-threads 10 // UNSUPPORTED: c++98, c++03 11 12 // <future> 13 14 // class shared_future<R> 15 16 // shared_future& operator=(shared_future&& rhs); 17 18 #include <future> 19 #include <cassert> 20 21 int main(int, char**) 22 { 23 { 24 typedef int T; 25 std::promise<T> p; 26 std::shared_future<T> f0 = p.get_future(); 27 std::shared_future<T> f; 28 f = std::move(f0); 29 assert(!f0.valid()); 30 assert(f.valid()); 31 } 32 { 33 typedef int T; 34 std::shared_future<T> f0; 35 std::shared_future<T> f; 36 f = std::move(f0); 37 assert(!f0.valid()); 38 assert(!f.valid()); 39 } 40 { 41 typedef int& T; 42 std::promise<T> p; 43 std::shared_future<T> f0 = p.get_future(); 44 std::shared_future<T> f; 45 f = std::move(f0); 46 assert(!f0.valid()); 47 assert(f.valid()); 48 } 49 { 50 typedef int& T; 51 std::shared_future<T> f0; 52 std::shared_future<T> f; 53 f = std::move(f0); 54 assert(!f0.valid()); 55 assert(!f.valid()); 56 } 57 { 58 typedef void T; 59 std::promise<T> p; 60 std::shared_future<T> f0 = p.get_future(); 61 std::shared_future<T> f; 62 f = std::move(f0); 63 assert(!f0.valid()); 64 assert(f.valid()); 65 } 66 { 67 typedef void T; 68 std::shared_future<T> f0; 69 std::shared_future<T> f; 70 f = std::move(f0); 71 assert(!f0.valid()); 72 assert(!f.valid()); 73 } 74 75 return 0; 76 } 77