Debian Codegraph @

libstdc++-v3/testsuite/20_util/uses_allocator/lwg3677.cc

raw
1 // { dg-do run { target c++20 } }
2 // { dg-require-effective-target hosted }
3
4 #include <memory>
5 #include <testsuite_hooks.h>
6
7 struct UsesAlloc
8 {
9 using allocator_type = std::allocator<int>;
10
11 bool passed_alloc;
12
13 UsesAlloc(int) : passed_alloc(false) { }
14
15 UsesAlloc(int, std::allocator<int>) : passed_alloc(true) { }
16 };
17
18 using Pair = std::pair<UsesAlloc, int>;
19
20 void
21 test_const()
22 {
23 std::allocator<int> a;
24 int i = 0;
25 auto p = std::make_obj_using_allocator<const Pair>(a, i, i);
26 VERIFY( p.first.passed_alloc );
27 }
28
29 void
30 test_volatile()
31 {
32 std::allocator<int> a;
33 int i = 0;
34 auto p = std::make_obj_using_allocator<volatile Pair>(a, i, i);
35 VERIFY( p.first.passed_alloc );
36 }
37
38 void
39 test_const_volatile()
40 {
41 std::allocator<int> a;
42 int i = 0;
43 auto p = std::make_obj_using_allocator<volatile Pair>(a, i, i);
44 VERIFY( p.first.passed_alloc );
45 }
46
47 int main()
48 {
49 test_const();
50 test_volatile();
51 test_const_volatile();
52 }