[AMDGPU] Mark AGPR tuple implicit in the first instr of AGPR spills. (#115285)
[llvm-project.git] / libcxx / test / std / thread / futures / futures.promise / alloc_ctor.pass.cpp
blob2e8b2aa53df9494ec9cc534e909e4322d704dde1
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 promise<R>
16 // template <class Allocator>
17 // promise(allocator_arg_t, const Allocator& a);
19 #include <future>
20 #include <cassert>
22 #include "test_macros.h"
23 #include "test_allocator.h"
24 #include "min_allocator.h"
26 int main(int, char**)
28 test_allocator_statistics alloc_stats;
29 assert(alloc_stats.alloc_count == 0);
31 std::promise<int> p(std::allocator_arg, test_allocator<int>(42, &alloc_stats));
32 assert(alloc_stats.alloc_count == 1);
33 std::future<int> f = p.get_future();
34 assert(alloc_stats.alloc_count == 1);
35 assert(f.valid());
37 assert(alloc_stats.alloc_count == 0);
39 std::promise<int&> p(std::allocator_arg, test_allocator<int>(42, &alloc_stats));
40 assert(alloc_stats.alloc_count == 1);
41 std::future<int&> f = p.get_future();
42 assert(alloc_stats.alloc_count == 1);
43 assert(f.valid());
45 assert(alloc_stats.alloc_count == 0);
47 std::promise<void> p(std::allocator_arg, test_allocator<void>(42, &alloc_stats));
48 assert(alloc_stats.alloc_count == 1);
49 std::future<void> f = p.get_future();
50 assert(alloc_stats.alloc_count == 1);
51 assert(f.valid());
53 assert(alloc_stats.alloc_count == 0);
54 // Test with a minimal allocator
56 std::promise<int> p(std::allocator_arg, bare_allocator<void>());
57 std::future<int> f = p.get_future();
58 assert(f.valid());
61 std::promise<int&> p(std::allocator_arg, bare_allocator<void>());
62 std::future<int&> f = p.get_future();
63 assert(f.valid());
66 std::promise<void> p(std::allocator_arg, bare_allocator<void>());
67 std::future<void> f = p.get_future();
68 assert(f.valid());
70 // Test with a minimal allocator that returns class-type pointers
72 std::promise<int> p(std::allocator_arg, min_allocator<void>());
73 std::future<int> f = p.get_future();
74 assert(f.valid());
77 std::promise<int&> p(std::allocator_arg, min_allocator<void>());
78 std::future<int&> f = p.get_future();
79 assert(f.valid());
82 std::promise<void> p(std::allocator_arg, min_allocator<void>());
83 std::future<void> f = p.get_future();
84 assert(f.valid());
87 return 0;