83 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8//9// UNSUPPORTED: no-threads10// UNSUPPORTED: c++0311 12// <future>13 14// class shared_future<R>15 16// shared_future& operator=(const shared_future& rhs);17// noexcept in C++1718 19#include <future>20#include <cassert>21 22#include "test_macros.h"23 24int main(int, char**)25{26 {27 typedef int T;28 std::promise<T> p;29 std::shared_future<T> f0 = p.get_future();30 std::shared_future<T> f;31 f = f0;32#if TEST_STD_VER > 1433 static_assert(noexcept(f = f0), "" );34#endif35 assert(f0.valid());36 assert(f.valid());37 }38 {39 typedef int T;40 std::shared_future<T> f0;41 std::shared_future<T> f;42 f = f0;43 assert(!f0.valid());44 assert(!f.valid());45 }46 {47 typedef int& T;48 std::promise<T> p;49 std::shared_future<T> f0 = p.get_future();50 std::shared_future<T> f;51 f = f0;52 assert(f0.valid());53 assert(f.valid());54 }55 {56 typedef int& T;57 std::shared_future<T> f0;58 std::shared_future<T> f;59 f = f0;60 assert(!f0.valid());61 assert(!f.valid());62 }63 {64 typedef void T;65 std::promise<T> p;66 std::shared_future<T> f0 = p.get_future();67 std::shared_future<T> f;68 f = f0;69 assert(f0.valid());70 assert(f.valid());71 }72 {73 typedef void T;74 std::shared_future<T> f0;75 std::shared_future<T> f;76 f = f0;77 assert(!f0.valid());78 assert(!f.valid());79 }80 81 return 0;82}83