[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / thread / futures / futures.unique_future / dtor.pass.cpp
blob05bfe2bea7f4f984849064d2ebe81d0051c7311f
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-exceptions
10 // UNSUPPORTED: libcpp-has-no-threads
11 // UNSUPPORTED: c++03
13 // <future>
15 // class future<R>
17 // ~future();
19 #include <future>
20 #include <cassert>
22 #include "test_macros.h"
23 #include "test_allocator.h"
25 int main(int, char**)
27 assert(test_alloc_base::alloc_count == 0);
29 typedef int T;
30 std::future<T> f;
32 std::promise<T> p(std::allocator_arg, test_allocator<T>());
33 assert(test_alloc_base::alloc_count == 1);
34 f = p.get_future();
35 assert(test_alloc_base::alloc_count == 1);
36 assert(f.valid());
38 assert(test_alloc_base::alloc_count == 1);
39 assert(f.valid());
41 assert(test_alloc_base::alloc_count == 0);
43 typedef int& T;
44 std::future<T> f;
46 std::promise<T> p(std::allocator_arg, test_allocator<int>());
47 assert(test_alloc_base::alloc_count == 1);
48 f = p.get_future();
49 assert(test_alloc_base::alloc_count == 1);
50 assert(f.valid());
52 assert(test_alloc_base::alloc_count == 1);
53 assert(f.valid());
55 assert(test_alloc_base::alloc_count == 0);
57 typedef void T;
58 std::future<T> f;
60 std::promise<T> p(std::allocator_arg, test_allocator<T>());
61 assert(test_alloc_base::alloc_count == 1);
62 f = p.get_future();
63 assert(test_alloc_base::alloc_count == 1);
64 assert(f.valid());
66 assert(test_alloc_base::alloc_count == 1);
67 assert(f.valid());
69 assert(test_alloc_base::alloc_count == 0);
71 return 0;