Skip to content

Commit 6e0efc9

Browse files
multimap.modifiers
1 parent 8b24123 commit 6e0efc9

16 files changed

+260
-185
lines changed

libcxx/include/__tree

Lines changed: 113 additions & 51 deletions
Large diffs are not rendered by default.

libcxx/test/std/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp

Lines changed: 51 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,34 @@
2525

2626
TEST_CONSTEXPR_CXX26
2727
bool test() {
28-
{
29-
typedef std::multimap<int, DefaultOnly> M;
30-
typedef M::iterator R;
31-
M m;
28+
// DefaultOnly::count is static
29+
if (!TEST_IS_CONSTANT_EVALUATED) {
30+
{
31+
typedef std::multimap<int, DefaultOnly> M;
32+
typedef M::iterator R;
33+
M m;
34+
assert(DefaultOnly::count == 0);
35+
R r = m.emplace();
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(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(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple());
48+
assert(r == std::next(m.begin(), 2));
49+
assert(m.size() == 3);
50+
assert(std::next(m.begin(), 2)->first == 1);
51+
assert(std::next(m.begin(), 2)->second == DefaultOnly());
52+
assert(DefaultOnly::count == 3);
53+
}
3254
assert(DefaultOnly::count == 0);
33-
R r = m.emplace();
34-
assert(r == m.begin());
35-
assert(m.size() == 1);
36-
assert(m.begin()->first == 0);
37-
assert(m.begin()->second == DefaultOnly());
38-
assert(DefaultOnly::count == 1);
39-
r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple());
40-
assert(r == std::next(m.begin()));
41-
assert(m.size() == 2);
42-
assert(std::next(m.begin())->first == 1);
43-
assert(std::next(m.begin())->second == DefaultOnly());
44-
assert(DefaultOnly::count == 2);
45-
r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple());
46-
assert(r == std::next(m.begin(), 2));
47-
assert(m.size() == 3);
48-
assert(std::next(m.begin(), 2)->first == 1);
49-
assert(std::next(m.begin(), 2)->second == DefaultOnly());
50-
assert(DefaultOnly::count == 3);
5155
}
52-
assert(DefaultOnly::count == 0);
5356
{
5457
typedef std::multimap<int, Emplaceable> M;
5558
typedef M::iterator R;
@@ -80,31 +83,33 @@ bool test() {
8083
assert(m.begin()->first == 2);
8184
assert(m.begin()->second == 3.5);
8285
}
83-
{
84-
typedef std::multimap<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M;
85-
typedef M::iterator R;
86-
M m;
86+
if (!TEST_IS_CONSTANT_EVALUATED) {
87+
{
88+
typedef std::multimap<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M;
89+
typedef M::iterator R;
90+
M m;
91+
assert(DefaultOnly::count == 0);
92+
R r = m.emplace();
93+
assert(r == m.begin());
94+
assert(m.size() == 1);
95+
assert(m.begin()->first == 0);
96+
assert(m.begin()->second == DefaultOnly());
97+
assert(DefaultOnly::count == 1);
98+
r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple());
99+
assert(r == std::next(m.begin()));
100+
assert(m.size() == 2);
101+
assert(std::next(m.begin())->first == 1);
102+
assert(std::next(m.begin())->second == DefaultOnly());
103+
assert(DefaultOnly::count == 2);
104+
r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple());
105+
assert(r == std::next(m.begin(), 2));
106+
assert(m.size() == 3);
107+
assert(std::next(m.begin(), 2)->first == 1);
108+
assert(std::next(m.begin(), 2)->second == DefaultOnly());
109+
assert(DefaultOnly::count == 3);
110+
}
87111
assert(DefaultOnly::count == 0);
88-
R r = m.emplace();
89-
assert(r == m.begin());
90-
assert(m.size() == 1);
91-
assert(m.begin()->first == 0);
92-
assert(m.begin()->second == DefaultOnly());
93-
assert(DefaultOnly::count == 1);
94-
r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple());
95-
assert(r == std::next(m.begin()));
96-
assert(m.size() == 2);
97-
assert(std::next(m.begin())->first == 1);
98-
assert(std::next(m.begin())->second == DefaultOnly());
99-
assert(DefaultOnly::count == 2);
100-
r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple());
101-
assert(r == std::next(m.begin(), 2));
102-
assert(m.size() == 3);
103-
assert(std::next(m.begin(), 2)->first == 1);
104-
assert(std::next(m.begin(), 2)->second == DefaultOnly());
105-
assert(DefaultOnly::count == 3);
106112
}
107-
assert(DefaultOnly::count == 0);
108113
{
109114
typedef std::multimap<int, Emplaceable, std::less<int>, min_allocator<std::pair<const int, Emplaceable>>> M;
110115
typedef M::iterator R;

libcxx/test/std/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp

Lines changed: 51 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,34 @@
2525

2626
TEST_CONSTEXPR_CXX26
2727
bool test() {
28-
{
29-
typedef std::multimap<int, DefaultOnly> M;
30-
typedef M::iterator R;
31-
M m;
28+
// DefaultOnly::count is static
29+
if (!TEST_IS_CONSTANT_EVALUATED) {
30+
{
31+
typedef std::multimap<int, DefaultOnly> M;
32+
typedef M::iterator R;
33+
M m;
34+
assert(DefaultOnly::count == 0);
35+
R r = m.emplace_hint(m.cend());
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.cend(), 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.cend(), std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple());
48+
assert(r == std::next(m.begin(), 2));
49+
assert(m.size() == 3);
50+
assert(std::next(m.begin(), 2)->first == 1);
51+
assert(std::next(m.begin(), 2)->second == DefaultOnly());
52+
assert(DefaultOnly::count == 3);
53+
}
3254
assert(DefaultOnly::count == 0);
33-
R r = m.emplace_hint(m.cend());
34-
assert(r == m.begin());
35-
assert(m.size() == 1);
36-
assert(m.begin()->first == 0);
37-
assert(m.begin()->second == DefaultOnly());
38-
assert(DefaultOnly::count == 1);
39-
r = m.emplace_hint(m.cend(), std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple());
40-
assert(r == std::next(m.begin()));
41-
assert(m.size() == 2);
42-
assert(std::next(m.begin())->first == 1);
43-
assert(std::next(m.begin())->second == DefaultOnly());
44-
assert(DefaultOnly::count == 2);
45-
r = m.emplace_hint(m.cend(), std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple());
46-
assert(r == std::next(m.begin(), 2));
47-
assert(m.size() == 3);
48-
assert(std::next(m.begin(), 2)->first == 1);
49-
assert(std::next(m.begin(), 2)->second == DefaultOnly());
50-
assert(DefaultOnly::count == 3);
5155
}
52-
assert(DefaultOnly::count == 0);
5356
{
5457
typedef std::multimap<int, Emplaceable> M;
5558
typedef M::iterator R;
@@ -80,31 +83,33 @@ bool test() {
8083
assert(m.begin()->first == 2);
8184
assert(m.begin()->second == 3.5);
8285
}
83-
{
84-
typedef std::multimap<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M;
85-
typedef M::iterator R;
86-
M m;
86+
if (!TEST_IS_CONSTANT_EVALUATED) {
87+
{
88+
typedef std::multimap<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M;
89+
typedef M::iterator R;
90+
M m;
91+
assert(DefaultOnly::count == 0);
92+
R r = m.emplace_hint(m.cend());
93+
assert(r == m.begin());
94+
assert(m.size() == 1);
95+
assert(m.begin()->first == 0);
96+
assert(m.begin()->second == DefaultOnly());
97+
assert(DefaultOnly::count == 1);
98+
r = m.emplace_hint(m.cend(), std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple());
99+
assert(r == std::next(m.begin()));
100+
assert(m.size() == 2);
101+
assert(std::next(m.begin())->first == 1);
102+
assert(std::next(m.begin())->second == DefaultOnly());
103+
assert(DefaultOnly::count == 2);
104+
r = m.emplace_hint(m.cend(), std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple());
105+
assert(r == std::next(m.begin(), 2));
106+
assert(m.size() == 3);
107+
assert(std::next(m.begin(), 2)->first == 1);
108+
assert(std::next(m.begin(), 2)->second == DefaultOnly());
109+
assert(DefaultOnly::count == 3);
110+
}
87111
assert(DefaultOnly::count == 0);
88-
R r = m.emplace_hint(m.cend());
89-
assert(r == m.begin());
90-
assert(m.size() == 1);
91-
assert(m.begin()->first == 0);
92-
assert(m.begin()->second == DefaultOnly());
93-
assert(DefaultOnly::count == 1);
94-
r = m.emplace_hint(m.cend(), std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple());
95-
assert(r == std::next(m.begin()));
96-
assert(m.size() == 2);
97-
assert(std::next(m.begin())->first == 1);
98-
assert(std::next(m.begin())->second == DefaultOnly());
99-
assert(DefaultOnly::count == 2);
100-
r = m.emplace_hint(m.cend(), std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple());
101-
assert(r == std::next(m.begin(), 2));
102-
assert(m.size() == 3);
103-
assert(std::next(m.begin(), 2)->first == 1);
104-
assert(std::next(m.begin(), 2)->second == DefaultOnly());
105-
assert(DefaultOnly::count == 3);
106112
}
107-
assert(DefaultOnly::count == 0);
108113
{
109114
typedef std::multimap<int, Emplaceable, std::less<int>, min_allocator<std::pair<const int, Emplaceable>>> M;
110115
typedef M::iterator R;

libcxx/test/std/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020

2121
struct TemplateConstructor {
2222
template <typename T>
23-
TemplateConstructor(const T&) {}
23+
TEST_CONSTEXPR_CXX26 TemplateConstructor(const T&) {}
2424
};
2525

26+
TEST_CONSTEXPR_CXX26
2627
bool operator<(const TemplateConstructor&, const TemplateConstructor&) { return false; }
2728

2829
TEST_CONSTEXPR_CXX26

libcxx/test/std/containers/associative/multimap/multimap.modifiers/extract_iterator.pass.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "Counter.h"
2121

2222
template <class Container>
23-
void test(Container& c) {
23+
TEST_CONSTEXPR_CXX26 void test(Container& c) {
2424
std::size_t sz = c.size();
2525

2626
auto some_key = c.cbegin()->first;
@@ -29,9 +29,13 @@ void test(Container& c) {
2929
auto key_value = first->first;
3030
typename Container::node_type t = c.extract(first++);
3131
--sz;
32-
assert(t.key() == key_value);
33-
t.key() = some_key;
34-
assert(t.key() == some_key);
32+
33+
if (!TEST_IS_CONSTANT_EVALUATED) {
34+
// FIXME: CWG1514: key() is not `constexpr`
35+
assert(t.key() == key_value);
36+
t.key() = some_key;
37+
assert(t.key() == some_key);
38+
}
3539
assert(t.get_allocator() == c.get_allocator());
3640
assert(sz == c.size());
3741
}
@@ -47,7 +51,8 @@ bool test() {
4751
test(m);
4852
}
4953

50-
{
54+
// Counter_base::gConstructed is static
55+
if (!TEST_IS_CONSTANT_EVALUATED) {
5156
std::multimap<Counter<int>, Counter<int>> m = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}};
5257
assert(Counter_base::gConstructed == 12);
5358
test(m);

libcxx/test/std/containers/associative/multimap/multimap.modifiers/extract_key.pass.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,19 @@
2020
#include "Counter.h"
2121

2222
template <class Container, class KeyTypeIter>
23-
void test(Container& c, KeyTypeIter first, KeyTypeIter last) {
23+
TEST_CONSTEXPR_CXX26 void test(Container& c, KeyTypeIter first, KeyTypeIter last) {
2424
std::size_t sz = c.size();
2525
assert((std::size_t)std::distance(first, last) == sz);
2626

2727
for (KeyTypeIter copy = first; copy != last; ++copy) {
2828
typename Container::node_type t = c.extract(*copy);
2929
assert(!t.empty());
3030
--sz;
31-
assert(t.key() == *copy);
32-
t.key() = *first; // We should be able to mutate key.
33-
assert(t.key() == *first);
31+
if (!TEST_IS_CONSTANT_EVALUATED) {
32+
assert(t.key() == *copy);
33+
t.key() = *first; // We should be able to mutate key.
34+
assert(t.key() == *first);
35+
}
3436
assert(t.get_allocator() == c.get_allocator());
3537
assert(sz == c.size());
3638
}
@@ -51,7 +53,8 @@ bool test() {
5153
test(m, std::begin(keys), std::end(keys));
5254
}
5355

54-
{
56+
// Counter_base::gConstructed is static
57+
if (!TEST_IS_CONSTANT_EVALUATED) {
5558
std::multimap<Counter<int>, Counter<int>> m = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}};
5659
{
5760
Counter<int> keys[] = {1, 2, 3, 4, 5, 6};

libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_allocator_requirements.pass.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,9 @@
2020
#include "container_test_types.h"
2121
#include "../../../map_allocator_requirement_test_templates.h"
2222

23-
TEST_CONSTEXPR_CXX26
24-
bool test() {
23+
int main(int, char**) {
2524
testMultimapInsert<TCT::multimap<> >();
2625
testMultimapInsertHint<TCT::multimap<> >();
2726

28-
return true;
29-
}
30-
int main(int, char**) {
31-
test();
32-
33-
#if TEST_STD_VER >= 26
34-
static_assert(test());
35-
#endif
3627
return 0;
3728
}

libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "min_allocator.h"
2020

2121
template <class Container>
22-
void do_insert_test() {
22+
TEST_CONSTEXPR_CXX26 void do_insert_test() {
2323
typedef Container M;
2424
typedef typename M::iterator R;
2525
typedef typename M::value_type VT;

libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "min_allocator.h"
2020

2121
template <class Container>
22-
void do_insert_hint_test() {
22+
TEST_CONSTEXPR_CXX26 void do_insert_hint_test() {
2323
typedef Container M;
2424
typedef typename M::iterator R;
2525
typedef typename M::value_type VT;

libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "test_macros.h"
2323

2424
template <class Iter, class Alloc>
25-
void test_alloc() {
25+
TEST_CONSTEXPR_CXX26 void test_alloc() {
2626
{ // Check that an empty range works correctly
2727
{ // Without elements in the container
2828
using Map = std::multimap<int, int, std::less<int>, Alloc>;

0 commit comments

Comments
 (0)