Skip to content

Commit 96903d9

Browse files
committed
review
1 parent f315d75 commit 96903d9

File tree

72 files changed

+1214
-1087
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1214
-1087
lines changed

libcxx/include/__flat_set/flat_set.h

Lines changed: 70 additions & 67 deletions
Large diffs are not rendered by default.

libcxx/test/std/containers/container.adaptors/flat.set/flat.set.capacity/empty.pass.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "min_allocator.h"
2525

2626
template <class KeyContainer>
27-
void test() {
27+
void test_one() {
2828
using Key = typename KeyContainer::value_type;
2929
using M = std::flat_set<Key, std::less<int>, KeyContainer>;
3030
M m;
@@ -38,11 +38,15 @@ void test() {
3838
assert(m.empty());
3939
}
4040

41+
void test() {
42+
test_one<std::vector<int>>();
43+
test_one<std::deque<int>>();
44+
test_one<MinSequenceContainer<int>>();
45+
test_one<std::vector<int, min_allocator<int>>>();
46+
}
47+
4148
int main(int, char**) {
42-
test<std::vector<int>>();
43-
test<std::deque<int>>();
44-
test<MinSequenceContainer<int>>();
45-
test<std::vector<int, min_allocator<int>>>();
49+
test();
4650

4751
return 0;
4852
}

libcxx/test/std/containers/container.adaptors/flat.set/flat.set.capacity/max_size.pass.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
#include "test_allocator.h"
2525
#include "test_macros.h"
2626

27-
int main(int, char**) {
27+
void test() {
28+
2829
{
2930
using A1 = limited_allocator<int, 10>;
3031
using C = std::flat_set<int, std::less<int>, std::vector<int, A1>>;
@@ -59,5 +60,10 @@ int main(int, char**) {
5960
assert(c.max_size() <= max_dist);
6061
assert(c.max_size() <= alloc_max_size(std::allocator<char>()));
6162
}
63+
}
64+
65+
int main(int, char**) {
66+
test();
67+
6268
return 0;
6369
}

libcxx/test/std/containers/container.adaptors/flat.set/flat.set.capacity/size.pass.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "min_allocator.h"
2424

2525
template <class KeyContainer>
26-
void test() {
26+
void test_one() {
2727
using M = std::flat_set<int, std::less<int>, KeyContainer>;
2828
using S = typename M::size_type;
2929
{
@@ -56,11 +56,15 @@ void test() {
5656
}
5757
}
5858

59+
void test() {
60+
test_one<std::vector<int>>();
61+
test_one<std::deque<int>>();
62+
test_one<MinSequenceContainer<int>>();
63+
test_one<std::vector<int, min_allocator<int>>>();
64+
}
65+
5966
int main(int, char**) {
60-
test<std::vector<int>>();
61-
test<std::deque<int>>();
62-
test<MinSequenceContainer<int>>();
63-
test<std::vector<int, min_allocator<int>>>();
67+
test();
6468

6569
return 0;
6670
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "test_allocator.h"
2323
#include "../../../test_compare.h"
2424

25-
int main(int, char**) {
25+
void test() {
2626
{
2727
// The constructors in this subclause shall not participate in overload
2828
// resolution unless uses_allocator_v<container_type, Alloc> is true.
@@ -55,6 +55,10 @@ int main(int, char**) {
5555
auto v = std::move(m).extract();
5656
assert(v.get_allocator().get_id() == 5);
5757
}
58+
}
59+
60+
int main(int, char**) {
61+
test();
5862

5963
return 0;
6064
}

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "min_allocator.h"
2525

2626
template <class KeyContainer>
27-
void test() {
27+
void test_one() {
2828
using Key = typename KeyContainer::value_type;
2929
using M = std::flat_set<Key, std::less<Key>, KeyContainer>;
3030
{
@@ -33,7 +33,6 @@ void test() {
3333
m = {3, 1, 2, 2, 3, 4, 3, 5, 6, 5};
3434
int expected[] = {1, 2, 3, 4, 5, 6};
3535
assert(std::ranges::equal(m, expected));
36-
LIBCPP_ASSERT(std::ranges::equal(m, expected));
3736
}
3837
{
3938
M m = {10, 8};
@@ -44,13 +43,17 @@ void test() {
4443
}
4544
}
4645

46+
void test() {
47+
test_one<std::vector<int>>();
48+
test_one<std::vector<int>>();
49+
test_one<std::deque<int>>();
50+
test_one<MinSequenceContainer<int>>();
51+
test_one<std::vector<int, min_allocator<int>>>();
52+
test_one<std::vector<int, min_allocator<int>>>();
53+
}
54+
4755
int main(int, char**) {
48-
test<std::vector<int>>();
49-
test<std::vector<int>>();
50-
test<std::deque<int>>();
51-
test<MinSequenceContainer<int>>();
52-
test<std::vector<int, min_allocator<int>>>();
53-
test<std::vector<int, min_allocator<int>>>();
56+
test();
5457

5558
return 0;
5659
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "../../../test_compare.h"
2525
#include "test_allocator.h"
2626

27-
int main(int, char**) {
27+
void test() {
2828
{
2929
// The constructors in this subclause shall not participate in overload
3030
// resolution unless uses_allocator_v<container_type, Alloc> is true.
@@ -78,6 +78,10 @@ int main(int, char**) {
7878
auto keys = std::move(m).extract();
7979
assert(keys.get_allocator() == A1(5));
8080
}
81+
}
82+
83+
int main(int, char**) {
84+
test();
8185

8286
return 0;
8387
}

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

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void conversion_test(T);
3636
template <class T, class... Args>
3737
concept ImplicitlyConstructible = requires(Args&&... args) { conversion_test<T>({std::forward<Args>(args)...}); };
3838

39-
int main(int, char**) {
39+
void test() {
4040
{
4141
// The constructors in this subclause shall not participate in overload
4242
// resolution unless uses_allocator_v<container_type, Alloc> is true.
@@ -116,21 +116,16 @@ int main(int, char**) {
116116
auto m = M(ks, A(4)); // replaces the allocators
117117
assert(!ks.empty()); // it was an lvalue above
118118
assert((m == M{1, 2, 3}));
119-
auto keys = std::move(m).extract();
119+
auto keys = M(m).extract();
120120
assert(keys.get_allocator() == A(4));
121-
}
122-
{
123-
// flat_set(container_type , const Allocator&)
121+
124122
// explicit(false)
125-
using A = test_allocator<int>;
126-
using M = std::flat_set<int, std::less<int>, std::deque<int, A>>;
127123
static_assert(ImplicitlyConstructible<M, const std::deque<int, A>&, const A&>);
128-
auto ks = std::deque<int, A>({1, 1, 1, 2, 2, 3, 2, 3, 3}, A(5));
129-
M m = {ks, A(4)}; // implicit ctor
130-
assert(!ks.empty()); // it was an lvalue above
131-
assert((m == M{1, 2, 3}));
132-
auto keys = std::move(m).extract();
133-
assert(keys.get_allocator() == A(4));
124+
M m2 = {ks, A(4)}; // implicit ctor
125+
assert(!ks.empty()); // it was an lvalue above
126+
assert(m2 == m);
127+
auto keys2 = std::move(m).extract();
128+
assert(keys2.get_allocator() == A(4));
134129
}
135130
{
136131
// flat_set(container_type , key_compare, const Allocator&)
@@ -153,6 +148,10 @@ int main(int, char**) {
153148
keys = std::move(m2).extract();
154149
assert(keys.get_allocator() == A(5));
155150
}
151+
}
152+
153+
int main(int, char**) {
154+
test();
156155

157156
return 0;
158157
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "../../../test_compare.h"
2222
#include "test_allocator.h"
2323

24-
int main(int, char**) {
24+
void test() {
2525
{
2626
using C = test_less<int>;
2727
std::vector<int, test_allocator<int>> ks({1, 3, 5}, test_allocator<int>(6));
@@ -59,6 +59,10 @@ int main(int, char**) {
5959
auto keys2 = std::move(mo).extract();
6060
assert(keys2.get_allocator() == other_allocator<int>(6));
6161
}
62+
}
63+
64+
int main(int, char**) {
65+
test();
6266

6367
return 0;
6468
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "../../../test_compare.h"
2424
#include "test_allocator.h"
2525

26-
int main(int, char**) {
26+
void test() {
2727
{
2828
// The constructors in this subclause shall not participate in overload
2929
// resolution unless uses_allocator_v<container_type, Alloc> is true.
@@ -58,6 +58,10 @@ int main(int, char**) {
5858
auto keys2 = std::move(mo).extract();
5959
assert(keys2.get_allocator() == test_allocator<int>(6));
6060
}
61+
}
62+
63+
int main(int, char**) {
64+
test();
6165

6266
return 0;
6367
}

libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/copy_assign.addressof.compile.pass.cpp

Lines changed: 0 additions & 30 deletions
This file was deleted.

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
#include <functional>
1818
#include <vector>
1919

20+
#include "operator_hijacker.h"
2021
#include "test_macros.h"
2122
#include "../../../test_compare.h"
2223
#include "test_allocator.h"
2324

24-
int main(int, char**) {
25+
void test() {
2526
{
2627
// test_allocator is not propagated
2728
using C = test_less<int>;
@@ -81,5 +82,19 @@ int main(int, char**) {
8182
m = static_cast<const M&>(m);
8283
assert((m == M{{1, 2}}));
8384
}
85+
{
86+
// Validate whether the container can be copy-assigned (move-assigned, swapped)
87+
// with an ADL-hijacking operator&
88+
std::flat_set<operator_hijacker> so;
89+
std::flat_set<operator_hijacker> s;
90+
s = so;
91+
s = std::move(so);
92+
swap(s, so);
93+
}
94+
}
95+
96+
int main(int, char**) {
97+
test();
98+
8499
return 0;
85100
}

0 commit comments

Comments
 (0)