Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / thread / futures / futures.shared_future / copy_assign.pass.cpp
blobf7f8d272c28c7ffee215a02dcec7db91819dbe32
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: no-threads
10 // UNSUPPORTED: c++03
12 // <future>
14 // class shared_future<R>
16 // shared_future& operator=(const shared_future& rhs);
17 // noexcept in C++17
19 #include <future>
20 #include <cassert>
22 #include "test_macros.h"
24 int main(int, char**)
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 > 14
33 static_assert(noexcept(f = f0), "" );
34 #endif
35 assert(f0.valid());
36 assert(f.valid());
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());
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());
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());
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());
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());
81 return 0;