Skip to content

Commit 141d361

Browse files
committed
address comments
1 parent ad78c09 commit 141d361

File tree

13 files changed

+271
-277
lines changed

13 files changed

+271
-277
lines changed

libcxx/test/libcxx/containers/container.adaptors/flat.multiset/insert_range.pass.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <cassert>
2121
#include <flat_set>
2222
#include <ranges>
23-
#include <sstream>
2423
#include <vector>
2524

2625
#include "../flat_helpers.h"

libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/alloc.pass.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,41 +25,40 @@
2525

2626
template <template <class...> class KeyContainer>
2727
constexpr void test() {
28-
{
29-
using A = test_allocator<short>;
30-
using M = std::flat_multiset<int, std::less<int>, KeyContainer<int, test_allocator<int>>>;
31-
M m(A(0, 5));
32-
assert(m.empty());
33-
assert(m.begin() == m.end());
34-
assert(std::move(m).extract().get_allocator().get_id() == 5);
35-
}
36-
}
37-
38-
constexpr bool test() {
3928
{
4029
// The constructors in this subclause shall not participate in overload
4130
// resolution unless uses_allocator_v<container_type, Alloc> is true
4231

4332
using C = test_less<int>;
4433
using A1 = test_allocator<int>;
4534
using A2 = other_allocator<int>;
46-
using V1 = std::vector<int, A1>;
47-
using V2 = std::vector<int, A2>;
35+
using V1 = KeyContainer<int, A1>;
36+
using V2 = KeyContainer<int, A2>;
4837
using M1 = std::flat_multiset<int, C, V1>;
4938
using M2 = std::flat_multiset<int, C, V2>;
5039
static_assert(std::is_constructible_v<M1, const A1&>);
5140
static_assert(std::is_constructible_v<M2, const A2&>);
5241
static_assert(!std::is_constructible_v<M1, const A2&>);
5342
static_assert(!std::is_constructible_v<M2, const A1&>);
5443
}
44+
{
45+
using A = test_allocator<short>;
46+
using M = std::flat_multiset<int, std::less<int>, KeyContainer<int, test_allocator<int>>>;
47+
M m(A(0, 5));
48+
assert(m.empty());
49+
assert(m.begin() == m.end());
50+
assert(std::move(m).extract().get_allocator().get_id() == 5);
51+
}
5552
{
5653
// explicit
57-
using M = std::flat_multiset<int, std::less<int>, std::vector<int, test_allocator<int>>>;
54+
using M = std::flat_multiset<int, std::less<int>, KeyContainer<int, test_allocator<int>>>;
5855

5956
static_assert(std::is_constructible_v<M, test_allocator<int>>);
6057
static_assert(!std::is_convertible_v<test_allocator<int>, M>);
6158
}
59+
}
6260

61+
constexpr bool test() {
6362
test<std::vector>();
6463
#ifndef __cpp_lib_constexpr_deque
6564
if (!TEST_IS_CONSTANT_EVALUATED)

libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/compare.pass.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,22 @@ constexpr void test_compare() {
4949

5050
template <template <class...> class KeyContainer>
5151
constexpr void test_compare_alloc() {
52+
{
53+
// The constructors in this subclause shall not participate in overload
54+
// resolution unless uses_allocator_v<container_type, Alloc> is true
55+
56+
using C = test_less<int>;
57+
using A1 = test_allocator<int>;
58+
using A2 = other_allocator<int>;
59+
using V1 = KeyContainer<int, A1>;
60+
using V2 = KeyContainer<int, A2>;
61+
using M1 = std::flat_multiset<int, C, V1>;
62+
using M2 = std::flat_multiset<int, C, V2>;
63+
static_assert(std::is_constructible_v<M1, const C&, const A1&>);
64+
static_assert(std::is_constructible_v<M2, const C&, const A2&>);
65+
static_assert(!std::is_constructible_v<M1, const C&, const A2&>);
66+
static_assert(!std::is_constructible_v<M2, const C&, const A1&>);
67+
}
5268
{
5369
using C = test_less<int>;
5470
using A1 = test_allocator<int>;
@@ -71,23 +87,6 @@ constexpr void test_compare_alloc() {
7187
}
7288

7389
constexpr bool test() {
74-
{
75-
// The constructors in this subclause shall not participate in overload
76-
// resolution unless uses_allocator_v<container_type, Alloc> is true
77-
78-
using C = test_less<int>;
79-
using A1 = test_allocator<int>;
80-
using A2 = other_allocator<int>;
81-
using V1 = std::vector<int, A1>;
82-
using V2 = std::vector<int, A2>;
83-
using M1 = std::flat_multiset<int, C, V1>;
84-
using M2 = std::flat_multiset<int, C, V2>;
85-
static_assert(std::is_constructible_v<M1, const C&, const A1&>);
86-
static_assert(std::is_constructible_v<M2, const C&, const A2&>);
87-
static_assert(!std::is_constructible_v<M1, const C&, const A2&>);
88-
static_assert(!std::is_constructible_v<M2, const C&, const A1&>);
89-
}
90-
9190
test_compare<std::vector<int>>();
9291
test_compare<MinSequenceContainer<int>>();
9392
test_compare<std::vector<int, min_allocator<int>>>();

libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/containers.pass.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,27 @@ concept ImplicitlyConstructible = requires(Args&&... args) { conversion_test<T>(
3737

3838
template <template <class...> class KeyContainer>
3939
constexpr void test() {
40+
{
41+
// The constructors in this subclause shall not participate in overload
42+
// resolution unless uses_allocator_v<container_type, Alloc> is true
43+
44+
using C = test_less<int>;
45+
using A1 = test_allocator<int>;
46+
using A2 = other_allocator<int>;
47+
using V1 = KeyContainer<int, A1>;
48+
using V2 = KeyContainer<int, A2>;
49+
using M1 = std::flat_multiset<int, C, V1>;
50+
using M2 = std::flat_multiset<int, C, V2>;
51+
static_assert(std::is_constructible_v<M1, const V1&, const A1&>);
52+
static_assert(std::is_constructible_v<M2, const V2&, const A2&>);
53+
static_assert(!std::is_constructible_v<M1, const V1&, const A2&>);
54+
static_assert(!std::is_constructible_v<M2, const V2&, const A1&>);
55+
56+
static_assert(std::is_constructible_v<M1, const V1&, const C&, const A1&>);
57+
static_assert(std::is_constructible_v<M2, const V2&, const C&, const A2&>);
58+
static_assert(!std::is_constructible_v<M1, const V1&, const C&, const A2&>);
59+
static_assert(!std::is_constructible_v<M2, const V2&, const C&, const A1&>);
60+
}
4061
{
4162
// flat_multiset(container_type)
4263
using M = std::flat_multiset<int, std::less<int>, KeyContainer<int>>;
@@ -136,27 +157,6 @@ constexpr void test() {
136157
}
137158

138159
constexpr bool test() {
139-
{
140-
// The constructors in this subclause shall not participate in overload
141-
// resolution unless uses_allocator_v<container_type, Alloc> is true
142-
143-
using C = test_less<int>;
144-
using A1 = test_allocator<int>;
145-
using A2 = other_allocator<int>;
146-
using V1 = std::vector<int, A1>;
147-
using V2 = std::vector<int, A2>;
148-
using M1 = std::flat_multiset<int, C, V1>;
149-
using M2 = std::flat_multiset<int, C, V2>;
150-
static_assert(std::is_constructible_v<M1, const V1&, const A1&>);
151-
static_assert(std::is_constructible_v<M2, const V2&, const A2&>);
152-
static_assert(!std::is_constructible_v<M1, const V1&, const A2&>);
153-
static_assert(!std::is_constructible_v<M2, const V2&, const A1&>);
154-
155-
static_assert(std::is_constructible_v<M1, const V1&, const C&, const A1&>);
156-
static_assert(std::is_constructible_v<M2, const V2&, const C&, const A2&>);
157-
static_assert(!std::is_constructible_v<M1, const V1&, const C&, const A2&>);
158-
static_assert(!std::is_constructible_v<M2, const V2&, const C&, const A1&>);
159-
}
160160

161161
test<std::vector>();
162162

libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/copy_alloc.pass.cpp

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,42 +25,43 @@
2525

2626
template <template <class...> class KeyContainer>
2727
constexpr void test() {
28-
using C = test_less<int>;
29-
KeyContainer<int, test_allocator<int>> ks({1, 3, 5, 5}, test_allocator<int>(6));
30-
using M = std::flat_multiset<int, C, decltype(ks)>;
31-
auto mo = M(ks, C(5));
32-
auto m = M(mo, test_allocator<int>(3));
33-
34-
assert(m.key_comp() == C(5));
35-
assert(std::ranges::equal(m, ks));
36-
auto keys = std::move(m).extract();
37-
assert(keys.get_allocator() == test_allocator<int>(3));
38-
39-
// mo is unchanged
40-
assert(mo.key_comp() == C(5));
41-
assert(std::ranges::equal(mo, ks));
42-
auto keys2 = std::move(mo).extract();
43-
assert(keys2.get_allocator() == test_allocator<int>(6));
44-
}
45-
46-
constexpr bool test() {
4728
{
4829
// The constructors in this subclause shall not participate in overload
4930
// resolution unless uses_allocator_v<container_type, Alloc> is true.
5031

5132
using C = test_less<int>;
5233
using A1 = test_allocator<int>;
5334
using A2 = other_allocator<int>;
54-
using V1 = std::vector<int, A1>;
55-
using V2 = std::vector<int, A2>;
35+
using V1 = KeyContainer<int, A1>;
36+
using V2 = KeyContainer<int, A2>;
5637
using M1 = std::flat_multiset<int, C, V1>;
5738
using M2 = std::flat_multiset<int, C, V2>;
5839
static_assert(std::is_constructible_v<M1, const M1&, const A1&>);
5940
static_assert(std::is_constructible_v<M2, const M2&, const A2&>);
6041
static_assert(!std::is_constructible_v<M1, const M1&, const A2&>);
6142
static_assert(!std::is_constructible_v<M2, const M2&, const A1&>);
6243
}
44+
{
45+
using C = test_less<int>;
46+
KeyContainer<int, test_allocator<int>> ks({1, 3, 5, 5}, test_allocator<int>(6));
47+
using M = std::flat_multiset<int, C, decltype(ks)>;
48+
auto mo = M(ks, C(5));
49+
auto m = M(mo, test_allocator<int>(3));
6350

51+
assert(m.key_comp() == C(5));
52+
assert(std::ranges::equal(m, ks));
53+
auto keys = std::move(m).extract();
54+
assert(keys.get_allocator() == test_allocator<int>(3));
55+
56+
// mo is unchanged
57+
assert(mo.key_comp() == C(5));
58+
assert(std::ranges::equal(mo, ks));
59+
auto keys2 = std::move(mo).extract();
60+
assert(keys2.get_allocator() == test_allocator<int>(6));
61+
}
62+
}
63+
64+
constexpr bool test() {
6465
test<std::vector>();
6566

6667
#ifndef __cpp_lib_constexpr_deque

libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/initializer_list.pass.cpp

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,45 @@ struct DefaultCtableComp {
3939

4040
template <template <class...> class KeyContainer>
4141
constexpr void test() {
42+
{
43+
// The constructors in this subclause shall not participate in overload
44+
// resolution unless uses_allocator_v<container_type, Alloc> is true.
45+
46+
using C = test_less<int>;
47+
using A1 = test_allocator<int>;
48+
using A2 = other_allocator<int>;
49+
using V1 = KeyContainer<int, A1>;
50+
using V2 = KeyContainer<int, A2>;
51+
using M1 = std::flat_multiset<int, C, V1>;
52+
using M2 = std::flat_multiset<int, C, V2>;
53+
using IL = std::initializer_list<int>;
54+
static_assert(std::is_constructible_v<M1, IL, const A1&>);
55+
static_assert(std::is_constructible_v<M2, IL, const A2&>);
56+
static_assert(!std::is_constructible_v<M1, IL, const A2&>);
57+
static_assert(!std::is_constructible_v<M2, IL, const A1&>);
58+
59+
static_assert(std::is_constructible_v<M1, IL, const C&, const A1&>);
60+
static_assert(std::is_constructible_v<M2, IL, const C&, const A2&>);
61+
static_assert(!std::is_constructible_v<M1, IL, const C&, const A2&>);
62+
static_assert(!std::is_constructible_v<M2, IL, const C&, const A1&>);
63+
}
64+
{
65+
// initializer_list<value_type> needs to match exactly
66+
using M = std::flat_multiset<int, std::less<int>, KeyContainer<int>>;
67+
using C = typename M::key_compare;
68+
static_assert(std::is_constructible_v<M, std::initializer_list<int>>);
69+
static_assert(std::is_constructible_v<M, std::initializer_list<int>, C>);
70+
static_assert(std::is_constructible_v<M, std::initializer_list<int>, C, std::allocator<int>>);
71+
static_assert(std::is_constructible_v<M, std::initializer_list<int>, std::allocator<int>>);
72+
static_assert(!std::is_constructible_v<M, std::initializer_list<const int>>);
73+
static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, C>);
74+
static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, C, std::allocator<int>>);
75+
static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, std::allocator<int>>);
76+
static_assert(!std::is_constructible_v<M, std::initializer_list<const int>>);
77+
static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, C>);
78+
static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, C, std::allocator<int>>);
79+
static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, std::allocator<int>>);
80+
}
4281
int expected[] = {1, 2, 2, 3, 3, 5};
4382
{
4483
// flat_multiset(initializer_list<value_type>);
@@ -110,47 +149,6 @@ constexpr void test() {
110149
}
111150

112151
constexpr bool test() {
113-
{
114-
// The constructors in this subclause shall not participate in overload
115-
// resolution unless uses_allocator_v<container_type, Alloc> is true.
116-
117-
using C = test_less<int>;
118-
using A1 = test_allocator<int>;
119-
using A2 = other_allocator<int>;
120-
using V1 = std::vector<int, A1>;
121-
using V2 = std::vector<int, A2>;
122-
using M1 = std::flat_multiset<int, C, V1>;
123-
using M2 = std::flat_multiset<int, C, V2>;
124-
using IL = std::initializer_list<int>;
125-
static_assert(std::is_constructible_v<M1, IL, const A1&>);
126-
static_assert(std::is_constructible_v<M2, IL, const A2&>);
127-
static_assert(!std::is_constructible_v<M1, IL, const A2&>);
128-
static_assert(!std::is_constructible_v<M2, IL, const A1&>);
129-
130-
static_assert(std::is_constructible_v<M1, IL, const C&, const A1&>);
131-
static_assert(std::is_constructible_v<M2, IL, const C&, const A2&>);
132-
static_assert(!std::is_constructible_v<M1, IL, const C&, const A2&>);
133-
static_assert(!std::is_constructible_v<M2, IL, const C&, const A1&>);
134-
}
135-
136-
{
137-
// initializer_list<value_type> needs to match exactly
138-
using M = std::flat_multiset<int>;
139-
using C = typename M::key_compare;
140-
static_assert(std::is_constructible_v<M, std::initializer_list<int>>);
141-
static_assert(std::is_constructible_v<M, std::initializer_list<int>, C>);
142-
static_assert(std::is_constructible_v<M, std::initializer_list<int>, C, std::allocator<int>>);
143-
static_assert(std::is_constructible_v<M, std::initializer_list<int>, std::allocator<int>>);
144-
static_assert(!std::is_constructible_v<M, std::initializer_list<const int>>);
145-
static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, C>);
146-
static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, C, std::allocator<int>>);
147-
static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, std::allocator<int>>);
148-
static_assert(!std::is_constructible_v<M, std::initializer_list<const int>>);
149-
static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, C>);
150-
static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, C, std::allocator<int>>);
151-
static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, std::allocator<int>>);
152-
}
153-
154152
test<std::vector>();
155153

156154
#ifndef __cpp_lib_constexpr_deque

libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/iter_iter.pass.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,30 @@
3232

3333
template <template <class...> class KeyContainer>
3434
constexpr void test() {
35+
{
36+
// The constructors in this subclause shall not participate in overload
37+
// resolution unless uses_allocator_v<container_type, Alloc> is true.
38+
39+
using C = test_less<int>;
40+
using A1 = test_allocator<int>;
41+
using A2 = other_allocator<int>;
42+
using V1 = KeyContainer<int, A1>;
43+
using V2 = KeyContainer<int, A2>;
44+
using M1 = std::flat_multiset<int, C, V1>;
45+
using M2 = std::flat_multiset<int, C, V2>;
46+
using Iter1 = typename M1::iterator;
47+
using Iter2 = typename M2::iterator;
48+
static_assert(std::is_constructible_v<M1, Iter1, Iter1, const A1&>);
49+
static_assert(std::is_constructible_v<M2, Iter2, Iter2, const A2&>);
50+
static_assert(!std::is_constructible_v<M1, Iter1, Iter1, const A2&>);
51+
static_assert(!std::is_constructible_v<M2, Iter2, Iter2, const A1&>);
52+
53+
static_assert(std::is_constructible_v<M1, Iter1, Iter1, const C&, const A1&>);
54+
static_assert(std::is_constructible_v<M2, Iter2, Iter2, const C&, const A2&>);
55+
static_assert(!std::is_constructible_v<M1, Iter1, Iter1, const C&, const A2&>);
56+
static_assert(!std::is_constructible_v<M2, Iter2, Iter2, const C&, const A1&>);
57+
}
58+
3559
int ar[] = {1, 1, 1, 2, 2, 3, 2, 3, 3};
3660
int expected[] = {1, 1, 1, 2, 2, 2, 3, 3, 3};
3761
{
@@ -112,30 +136,6 @@ constexpr void test() {
112136
}
113137

114138
constexpr bool test() {
115-
{
116-
// The constructors in this subclause shall not participate in overload
117-
// resolution unless uses_allocator_v<container_type, Alloc> is true.
118-
119-
using C = test_less<int>;
120-
using A1 = test_allocator<int>;
121-
using A2 = other_allocator<int>;
122-
using V1 = std::vector<int, A1>;
123-
using V2 = std::vector<int, A2>;
124-
using M1 = std::flat_multiset<int, C, V1>;
125-
using M2 = std::flat_multiset<int, C, V2>;
126-
using Iter1 = typename M1::iterator;
127-
using Iter2 = typename M2::iterator;
128-
static_assert(std::is_constructible_v<M1, Iter1, Iter1, const A1&>);
129-
static_assert(std::is_constructible_v<M2, Iter2, Iter2, const A2&>);
130-
static_assert(!std::is_constructible_v<M1, Iter1, Iter1, const A2&>);
131-
static_assert(!std::is_constructible_v<M2, Iter2, Iter2, const A1&>);
132-
133-
static_assert(std::is_constructible_v<M1, Iter1, Iter1, const C&, const A1&>);
134-
static_assert(std::is_constructible_v<M2, Iter2, Iter2, const C&, const A2&>);
135-
static_assert(!std::is_constructible_v<M1, Iter1, Iter1, const C&, const A2&>);
136-
static_assert(!std::is_constructible_v<M2, Iter2, Iter2, const C&, const A1&>);
137-
}
138-
139139
test<std::vector>();
140140
#ifndef __cpp_lib_constexpr_deque
141141
if (!TEST_IS_CONSTANT_EVALUATED)

0 commit comments

Comments
 (0)