|
24 | 24 | #include "min_allocator.h" |
25 | 25 |
|
26 | 26 | TEST_CONSTEXPR_CXX26 bool test() { |
| 27 | + |
| 28 | + if(!TEST_IS_CONSTANT_EVALUATED) |
27 | 29 | { |
28 | | - typedef std::map<int, DefaultOnly> M; |
29 | | - typedef M::iterator R; |
30 | | - M m; |
| 30 | + { |
| 31 | + typedef std::map<int, DefaultOnly> M; |
| 32 | + typedef M::iterator R; |
| 33 | + M m; |
| 34 | + assert(DefaultOnly::count == 0); |
| 35 | + R r = m.emplace_hint(m.end()); |
| 36 | + assert(r == m.begin()); |
| 37 | + assert(m.size() == 1); |
| 38 | + assert(m.begin()->first == 0); |
| 39 | + assert(m.begin()->second == DefaultOnly()); |
| 40 | + assert(DefaultOnly::count == 1); |
| 41 | + r = m.emplace_hint(m.end(), std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple()); |
| 42 | + assert(r == std::next(m.begin())); |
| 43 | + assert(m.size() == 2); |
| 44 | + assert(std::next(m.begin())->first == 1); |
| 45 | + assert(std::next(m.begin())->second == DefaultOnly()); |
| 46 | + assert(DefaultOnly::count == 2); |
| 47 | + r = m.emplace_hint(m.end(), std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple()); |
| 48 | + assert(r == std::next(m.begin())); |
| 49 | + assert(m.size() == 2); |
| 50 | + assert(std::next(m.begin())->first == 1); |
| 51 | + assert(std::next(m.begin())->second == DefaultOnly()); |
| 52 | + assert(DefaultOnly::count == 2); |
| 53 | + } |
31 | 54 | assert(DefaultOnly::count == 0); |
32 | | - R r = m.emplace_hint(m.end()); |
33 | | - assert(r == m.begin()); |
34 | | - assert(m.size() == 1); |
35 | | - assert(m.begin()->first == 0); |
36 | | - assert(m.begin()->second == DefaultOnly()); |
37 | | - assert(DefaultOnly::count == 1); |
38 | | - r = m.emplace_hint(m.end(), std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple()); |
39 | | - assert(r == std::next(m.begin())); |
40 | | - assert(m.size() == 2); |
41 | | - assert(std::next(m.begin())->first == 1); |
42 | | - assert(std::next(m.begin())->second == DefaultOnly()); |
43 | | - assert(DefaultOnly::count == 2); |
44 | | - r = m.emplace_hint(m.end(), std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple()); |
45 | | - assert(r == std::next(m.begin())); |
46 | | - assert(m.size() == 2); |
47 | | - assert(std::next(m.begin())->first == 1); |
48 | | - assert(std::next(m.begin())->second == DefaultOnly()); |
49 | | - assert(DefaultOnly::count == 2); |
50 | 55 | } |
51 | | - assert(DefaultOnly::count == 0); |
| 56 | + |
52 | 57 | { |
53 | 58 | typedef std::map<int, Emplaceable> M; |
54 | 59 | typedef M::iterator R; |
@@ -79,31 +84,36 @@ TEST_CONSTEXPR_CXX26 bool test() { |
79 | 84 | assert(m.begin()->first == 2); |
80 | 85 | assert(m.begin()->second == 3.5); |
81 | 86 | } |
| 87 | + |
| 88 | + if(!TEST_IS_CONSTANT_EVALUATED) |
82 | 89 | { |
83 | | - typedef std::map<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M; |
84 | | - typedef M::iterator R; |
85 | | - M m; |
| 90 | + { |
| 91 | + typedef std::map<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M; |
| 92 | + typedef M::iterator R; |
| 93 | + M m; |
| 94 | + assert(DefaultOnly::count == 0); |
| 95 | + R r = m.emplace_hint(m.end()); |
| 96 | + assert(r == m.begin()); |
| 97 | + assert(m.size() == 1); |
| 98 | + assert(m.begin()->first == 0); |
| 99 | + assert(m.begin()->second == DefaultOnly()); |
| 100 | + assert(DefaultOnly::count == 1); |
| 101 | + r = m.emplace_hint(m.end(), std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple()); |
| 102 | + assert(r == std::next(m.begin())); |
| 103 | + assert(m.size() == 2); |
| 104 | + assert(std::next(m.begin())->first == 1); |
| 105 | + assert(std::next(m.begin())->second == DefaultOnly()); |
| 106 | + assert(DefaultOnly::count == 2); |
| 107 | + r = m.emplace_hint(m.end(), std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple()); |
| 108 | + assert(r == std::next(m.begin())); |
| 109 | + assert(m.size() == 2); |
| 110 | + assert(std::next(m.begin())->first == 1); |
| 111 | + assert(std::next(m.begin())->second == DefaultOnly()); |
| 112 | + assert(DefaultOnly::count == 2); |
| 113 | + } |
86 | 114 | assert(DefaultOnly::count == 0); |
87 | | - R r = m.emplace_hint(m.end()); |
88 | | - assert(r == m.begin()); |
89 | | - assert(m.size() == 1); |
90 | | - assert(m.begin()->first == 0); |
91 | | - assert(m.begin()->second == DefaultOnly()); |
92 | | - assert(DefaultOnly::count == 1); |
93 | | - r = m.emplace_hint(m.end(), std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple()); |
94 | | - assert(r == std::next(m.begin())); |
95 | | - assert(m.size() == 2); |
96 | | - assert(std::next(m.begin())->first == 1); |
97 | | - assert(std::next(m.begin())->second == DefaultOnly()); |
98 | | - assert(DefaultOnly::count == 2); |
99 | | - r = m.emplace_hint(m.end(), std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple()); |
100 | | - assert(r == std::next(m.begin())); |
101 | | - assert(m.size() == 2); |
102 | | - assert(std::next(m.begin())->first == 1); |
103 | | - assert(std::next(m.begin())->second == DefaultOnly()); |
104 | | - assert(DefaultOnly::count == 2); |
105 | 115 | } |
106 | | - assert(DefaultOnly::count == 0); |
| 116 | + |
107 | 117 | { |
108 | 118 | typedef std::map<int, Emplaceable, std::less<int>, min_allocator<std::pair<const int, Emplaceable>>> M; |
109 | 119 | typedef M::iterator R; |
|
0 commit comments