ELF: Have __rela_iplt_{start,end} surround .rela.iplt with --pack-dyn-relocs=android.
[llvm-project.git] / libcxx / test / std / thread / futures / futures.shared_future / dtor.pass.cpp
blob4a65daf640dada9a5cbf80c6dc634b47bfe9562a
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: no-threads
11 // UNSUPPORTED: c++03
13 // <future>
15 // class shared_future<R>
17 // ~shared_future();
19 #include <future>
20 #include <cassert>
22 #include "test_macros.h"
23 #include "test_allocator.h"
25 int main(int, char**)
27 test_allocator_statistics alloc_stats;
28 assert(alloc_stats.alloc_count == 0);
30 typedef int T;
31 std::shared_future<T> f;
33 std::promise<T> p(std::allocator_arg, test_allocator<T>(&alloc_stats));
34 assert(alloc_stats.alloc_count == 1);
35 f = p.get_future();
36 assert(alloc_stats.alloc_count == 1);
37 assert(f.valid());
39 assert(alloc_stats.alloc_count == 1);
40 assert(f.valid());
42 assert(alloc_stats.alloc_count == 0);
44 typedef int& T;
45 std::shared_future<T> f;
47 std::promise<T> p(std::allocator_arg, test_allocator<int>(&alloc_stats));
48 assert(alloc_stats.alloc_count == 1);
49 f = p.get_future();
50 assert(alloc_stats.alloc_count == 1);
51 assert(f.valid());
53 assert(alloc_stats.alloc_count == 1);
54 assert(f.valid());
56 assert(alloc_stats.alloc_count == 0);
58 typedef void T;
59 std::shared_future<T> f;
61 std::promise<T> p(std::allocator_arg, test_allocator<T>(&alloc_stats));
62 assert(alloc_stats.alloc_count == 1);
63 f = p.get_future();
64 assert(alloc_stats.alloc_count == 1);
65 assert(f.valid());
67 assert(alloc_stats.alloc_count == 1);
68 assert(f.valid());
70 assert(alloc_stats.alloc_count == 0);
72 return 0;