summaryrefslogtreecommitdiffstats
path: root/libcxx/test/containers/associative/map
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2013-06-19 21:29:40 +0000
committerHoward Hinnant <hhinnant@apple.com>2013-06-19 21:29:40 +0000
commit07d3eccd26a600a6cad3bb6807880f46a76f269e (patch)
tree8f9a3056982d04fbb15a89146326e7a7834aabe5 /libcxx/test/containers/associative/map
parent64f440518b3dc41da99ace80d9289bfa8d92aa15 (diff)
downloadbcm5719-llvm-07d3eccd26a600a6cad3bb6807880f46a76f269e.tar.gz
bcm5719-llvm-07d3eccd26a600a6cad3bb6807880f46a76f269e.zip
Implement full support for non-pointer types in custom allocators. This is for the associative containers only. This work still needs to be done on the unordered and sequence containers. Fixes http://llvm.org/bugs/show_bug.cgi?id=15978
llvm-svn: 184358
Diffstat (limited to 'libcxx/test/containers/associative/map')
-rw-r--r--libcxx/test/containers/associative/map/map.access/at.pass.cpp68
-rw-r--r--libcxx/test/containers/associative/map/map.access/empty.pass.cpp15
-rw-r--r--libcxx/test/containers/associative/map/map.access/index_key.pass.cpp32
-rw-r--r--libcxx/test/containers/associative/map/map.access/index_rv_key.pass.cpp20
-rw-r--r--libcxx/test/containers/associative/map/map.access/iterator.pass.cpp90
-rw-r--r--libcxx/test/containers/associative/map/map.access/max_size.pass.cpp11
-rw-r--r--libcxx/test/containers/associative/map/map.access/size.pass.cpp23
-rw-r--r--libcxx/test/containers/associative/map/map.cons/alloc.pass.cpp13
-rw-r--r--libcxx/test/containers/associative/map/map.cons/assign_initializer_list.pass.cpp30
-rw-r--r--libcxx/test/containers/associative/map/map.cons/compare.pass.cpp12
-rw-r--r--libcxx/test/containers/associative/map/map.cons/compare_alloc.pass.cpp14
-rw-r--r--libcxx/test/containers/associative/map/map.cons/copy.pass.cpp37
-rw-r--r--libcxx/test/containers/associative/map/map.cons/copy_alloc.pass.cpp39
-rw-r--r--libcxx/test/containers/associative/map/map.cons/copy_assign.pass.cpp73
-rw-r--r--libcxx/test/containers/associative/map/map.cons/default.pass.cpp11
-rw-r--r--libcxx/test/containers/associative/map/map.cons/default_recursive.pass.cpp2
-rw-r--r--libcxx/test/containers/associative/map/map.cons/initializer_list.pass.cpp26
-rw-r--r--libcxx/test/containers/associative/map/map.cons/initializer_list_compare.pass.cpp26
-rw-r--r--libcxx/test/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp28
-rw-r--r--libcxx/test/containers/associative/map/map.cons/iter_iter.pass.cpp27
-rw-r--r--libcxx/test/containers/associative/map/map.cons/iter_iter_comp.pass.cpp28
-rw-r--r--libcxx/test/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp30
-rw-r--r--libcxx/test/containers/associative/map/map.cons/move.pass.cpp48
-rw-r--r--libcxx/test/containers/associative/map/map.cons/move_alloc.pass.cpp42
-rw-r--r--libcxx/test/containers/associative/map/map.cons/move_assign.pass.cpp43
-rw-r--r--libcxx/test/containers/associative/map/map.modifiers/clear.pass.cpp23
-rw-r--r--libcxx/test/containers/associative/map/map.modifiers/emplace.pass.cpp67
-rw-r--r--libcxx/test/containers/associative/map/map.modifiers/emplace_hint.pass.cpp62
-rw-r--r--libcxx/test/containers/associative/map/map.modifiers/erase_iter.pass.cpp110
-rw-r--r--libcxx/test/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp70
-rw-r--r--libcxx/test/containers/associative/map/map.modifiers/erase_key.pass.cpp129
-rw-r--r--libcxx/test/containers/associative/map/map.modifiers/insert_cv.pass.cpp36
-rw-r--r--libcxx/test/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp28
-rw-r--r--libcxx/test/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp32
-rw-r--r--libcxx/test/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp28
-rw-r--r--libcxx/test/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp32
-rw-r--r--libcxx/test/containers/associative/map/map.modifiers/insert_rv.pass.cpp35
-rw-r--r--libcxx/test/containers/associative/map/map.ops/count.pass.cpp43
-rw-r--r--libcxx/test/containers/associative/map/map.ops/equal_range.pass.cpp142
-rw-r--r--libcxx/test/containers/associative/map/map.ops/find.pass.cpp76
-rw-r--r--libcxx/test/containers/associative/map/map.ops/lower_bound.pass.cpp108
-rw-r--r--libcxx/test/containers/associative/map/map.ops/upper_bound.pass.cpp108
-rw-r--r--libcxx/test/containers/associative/map/map.special/member_swap.pass.cpp94
-rw-r--r--libcxx/test/containers/associative/map/map.special/non_member_swap.pass.cpp127
-rw-r--r--libcxx/test/containers/associative/map/types.pass.cpp19
45 files changed, 2156 insertions, 1 deletions
diff --git a/libcxx/test/containers/associative/map/map.access/at.pass.cpp b/libcxx/test/containers/associative/map/map.access/at.pass.cpp
index 09f70b0f88d..6c001a34428 100644
--- a/libcxx/test/containers/associative/map/map.access/at.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.access/at.pass.cpp
@@ -17,6 +17,8 @@
#include <map>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
{
@@ -83,4 +85,70 @@ int main()
assert(m.at(8) == 8.5);
assert(m.size() == 7);
}
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1.5),
+ V(2, 2.5),
+ V(3, 3.5),
+ V(4, 4.5),
+ V(5, 5.5),
+ V(7, 7.5),
+ V(8, 8.5),
+ };
+ std::map<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 7);
+ assert(m.at(1) == 1.5);
+ m.at(1) = -1.5;
+ assert(m.at(1) == -1.5);
+ assert(m.at(2) == 2.5);
+ assert(m.at(3) == 3.5);
+ assert(m.at(4) == 4.5);
+ assert(m.at(5) == 5.5);
+ try
+ {
+ m.at(6);
+ assert(false);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ assert(m.at(7) == 7.5);
+ assert(m.at(8) == 8.5);
+ assert(m.size() == 7);
+ }
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1.5),
+ V(2, 2.5),
+ V(3, 3.5),
+ V(4, 4.5),
+ V(5, 5.5),
+ V(7, 7.5),
+ V(8, 8.5),
+ };
+ const std::map<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 7);
+ assert(m.at(1) == 1.5);
+ assert(m.at(2) == 2.5);
+ assert(m.at(3) == 3.5);
+ assert(m.at(4) == 4.5);
+ assert(m.at(5) == 5.5);
+ try
+ {
+ m.at(6);
+ assert(false);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ assert(m.at(7) == 7.5);
+ assert(m.at(8) == 8.5);
+ assert(m.size() == 7);
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.access/empty.pass.cpp b/libcxx/test/containers/associative/map/map.access/empty.pass.cpp
index b654117f7a7..2e542ac8c32 100644
--- a/libcxx/test/containers/associative/map/map.access/empty.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.access/empty.pass.cpp
@@ -16,8 +16,11 @@
#include <map>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
+ {
typedef std::map<int, double> M;
M m;
assert(m.empty());
@@ -25,4 +28,16 @@ int main()
assert(!m.empty());
m.clear();
assert(m.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ M m;
+ assert(m.empty());
+ m.insert(M::value_type(1, 1.5));
+ assert(!m.empty());
+ m.clear();
+ assert(m.empty());
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.access/index_key.pass.cpp b/libcxx/test/containers/associative/map/map.access/index_key.pass.cpp
index fb82bbedf81..7579088784c 100644
--- a/libcxx/test/containers/associative/map/map.access/index_key.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.access/index_key.pass.cpp
@@ -16,8 +16,11 @@
#include <map>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
+ {
typedef std::pair<const int, double> V;
V ar[] =
{
@@ -41,4 +44,33 @@ int main()
m[6] = 6.5;
assert(m[6] == 6.5);
assert(m.size() == 8);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1.5),
+ V(2, 2.5),
+ V(3, 3.5),
+ V(4, 4.5),
+ V(5, 5.5),
+ V(7, 7.5),
+ V(8, 8.5),
+ };
+ std::map<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 7);
+ assert(m[1] == 1.5);
+ assert(m.size() == 7);
+ const int i = 1;
+ m[i] = -1.5;
+ assert(m[1] == -1.5);
+ assert(m.size() == 7);
+ assert(m[6] == 0);
+ assert(m.size() == 8);
+ m[6] = 6.5;
+ assert(m[6] == 6.5);
+ assert(m.size() == 8);
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.access/index_rv_key.pass.cpp b/libcxx/test/containers/associative/map/map.access/index_rv_key.pass.cpp
index 4efe88c80d7..4c15f088fae 100644
--- a/libcxx/test/containers/associative/map/map.access/index_rv_key.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.access/index_rv_key.pass.cpp
@@ -17,10 +17,12 @@
#include <cassert>
#include "../../../MoveOnly.h"
+#include "../../../min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
typedef std::pair<MoveOnly, double> V;
std::map<MoveOnly, double> m;
assert(m.size() == 0);
@@ -34,5 +36,23 @@ int main()
m[6] = 6.5;
assert(m[6] == 6.5);
assert(m.size() == 2);
+ }
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<MoveOnly, double> V;
+ std::map<MoveOnly, double, std::less<MoveOnly>, min_allocator<V>> m;
+ assert(m.size() == 0);
+ assert(m[1] == 0.0);
+ assert(m.size() == 1);
+ m[1] = -1.5;
+ assert(m[1] == -1.5);
+ assert(m.size() == 1);
+ assert(m[6] == 0);
+ assert(m.size() == 2);
+ m[6] = 6.5;
+ assert(m[6] == 6.5);
+ assert(m.size() == 2);
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.access/iterator.pass.cpp b/libcxx/test/containers/associative/map/map.access/iterator.pass.cpp
index d8b2e1a58d5..048c074c296 100644
--- a/libcxx/test/containers/associative/map/map.access/iterator.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.access/iterator.pass.cpp
@@ -29,6 +29,8 @@
#include <map>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
{
@@ -117,4 +119,92 @@ int main()
assert(i->second == 1);
}
}
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ V(4, 1),
+ V(4, 1.5),
+ V(4, 2),
+ V(5, 1),
+ V(5, 1.5),
+ V(5, 2),
+ V(6, 1),
+ V(6, 1.5),
+ V(6, 2),
+ V(7, 1),
+ V(7, 1.5),
+ V(7, 2),
+ V(8, 1),
+ V(8, 1.5),
+ V(8, 2)
+ };
+ std::map<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ std::map<int, double, std::less<int>, min_allocator<V>>::iterator i;
+ i = m.begin();
+ std::map<int, double, std::less<int>, min_allocator<V>>::const_iterator k = i;
+ assert(i == k);
+ for (int j = 1; j <= m.size(); ++j, ++i)
+ {
+ assert(i->first == j);
+ assert(i->second == 1);
+ i->second = 2.5;
+ assert(i->second == 2.5);
+ }
+ }
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ V(4, 1),
+ V(4, 1.5),
+ V(4, 2),
+ V(5, 1),
+ V(5, 1.5),
+ V(5, 2),
+ V(6, 1),
+ V(6, 1.5),
+ V(6, 2),
+ V(7, 1),
+ V(7, 1.5),
+ V(7, 2),
+ V(8, 1),
+ V(8, 1.5),
+ V(8, 2)
+ };
+ const std::map<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.cbegin(), m.cend()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ assert(std::distance(m.crbegin(), m.crend()) == m.size());
+ std::map<int, double, std::less<int>, min_allocator<V>>::const_iterator i;
+ i = m.begin();
+ for (int j = 1; j <= m.size(); ++j, ++i)
+ {
+ assert(i->first == j);
+ assert(i->second == 1);
+ }
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.access/max_size.pass.cpp b/libcxx/test/containers/associative/map/map.access/max_size.pass.cpp
index e63587d4b43..6f86d0e9de8 100644
--- a/libcxx/test/containers/associative/map/map.access/max_size.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.access/max_size.pass.cpp
@@ -16,9 +16,20 @@
#include <map>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
+ {
typedef std::map<int, double> M;
M m;
assert(m.max_size() != 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ M m;
+ assert(m.max_size() != 0);
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.access/size.pass.cpp b/libcxx/test/containers/associative/map/map.access/size.pass.cpp
index ab4d7c63c33..ab4b05baa5a 100644
--- a/libcxx/test/containers/associative/map/map.access/size.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.access/size.pass.cpp
@@ -16,8 +16,11 @@
#include <map>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
+ {
typedef std::map<int, double> M;
M m;
assert(m.size() == 0);
@@ -33,4 +36,24 @@ int main()
assert(m.size() == 1);
m.erase(m.begin());
assert(m.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ M m;
+ assert(m.size() == 0);
+ m.insert(M::value_type(2, 1.5));
+ assert(m.size() == 1);
+ m.insert(M::value_type(1, 1.5));
+ assert(m.size() == 2);
+ m.insert(M::value_type(3, 1.5));
+ assert(m.size() == 3);
+ m.erase(m.begin());
+ assert(m.size() == 2);
+ m.erase(m.begin());
+ assert(m.size() == 1);
+ m.erase(m.begin());
+ assert(m.size() == 0);
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.cons/alloc.pass.cpp b/libcxx/test/containers/associative/map/map.cons/alloc.pass.cpp
index 1a77f60564c..95d71da664a 100644
--- a/libcxx/test/containers/associative/map/map.cons/alloc.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.cons/alloc.pass.cpp
@@ -17,13 +17,26 @@
#include <cassert>
#include "../../../test_allocator.h"
+#include "../../../min_allocator.h"
int main()
{
+ {
typedef std::less<int> C;
typedef test_allocator<std::pair<const int, double> > A;
std::map<int, double, C, A> m(A(5));
assert(m.empty());
assert(m.begin() == m.end());
assert(m.get_allocator() == A(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::less<int> C;
+ typedef min_allocator<std::pair<const int, double> > A;
+ std::map<int, double, C, A> m(A{});
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.get_allocator() == A());
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.cons/assign_initializer_list.pass.cpp b/libcxx/test/containers/associative/map/map.cons/assign_initializer_list.pass.cpp
index 2fdf5b294af..a583f0d597f 100644
--- a/libcxx/test/containers/associative/map/map.cons/assign_initializer_list.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.cons/assign_initializer_list.pass.cpp
@@ -16,9 +16,12 @@
#include <map>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
typedef std::pair<const int, double> V;
std::map<int, double> m =
{
@@ -41,5 +44,32 @@ int main()
assert(*m.begin() == V(1, 1));
assert(*next(m.begin()) == V(2, 1));
assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ std::map<int, double, std::less<int>, min_allocator<V>> m =
+ {
+ {20, 1},
+ };
+ m =
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ };
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}
diff --git a/libcxx/test/containers/associative/map/map.cons/compare.pass.cpp b/libcxx/test/containers/associative/map/map.cons/compare.pass.cpp
index 5648ff0fb66..2c4bb1a8cbc 100644
--- a/libcxx/test/containers/associative/map/map.cons/compare.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.cons/compare.pass.cpp
@@ -17,12 +17,24 @@
#include <cassert>
#include "../../../test_compare.h"
+#include "../../../min_allocator.h"
int main()
{
+ {
typedef test_compare<std::less<int> > C;
std::map<int, double, C> m(C(3));
assert(m.empty());
assert(m.begin() == m.end());
assert(m.key_comp() == C(3));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_compare<std::less<int> > C;
+ std::map<int, double, C, min_allocator<std::pair<const int, double>>> m(C(3));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(3));
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.cons/compare_alloc.pass.cpp b/libcxx/test/containers/associative/map/map.cons/compare_alloc.pass.cpp
index 26efa0dabc8..670acffc458 100644
--- a/libcxx/test/containers/associative/map/map.cons/compare_alloc.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.cons/compare_alloc.pass.cpp
@@ -18,9 +18,11 @@
#include "../../../test_compare.h"
#include "../../../test_allocator.h"
+#include "../../../min_allocator.h"
int main()
{
+ {
typedef test_compare<std::less<int> > C;
typedef test_allocator<std::pair<const int, double> > A;
std::map<int, double, C, A> m(C(4), A(5));
@@ -28,4 +30,16 @@ int main()
assert(m.begin() == m.end());
assert(m.key_comp() == C(4));
assert(m.get_allocator() == A(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<std::pair<const int, double> > A;
+ std::map<int, double, C, A> m(C(4), A());
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(4));
+ assert(m.get_allocator() == A());
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.cons/copy.pass.cpp b/libcxx/test/containers/associative/map/map.cons/copy.pass.cpp
index 01c0d89d5e4..ce20d69d7c9 100644
--- a/libcxx/test/containers/associative/map/map.cons/copy.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.cons/copy.pass.cpp
@@ -18,6 +18,7 @@
#include "../../../test_compare.h"
#include "../../../test_allocator.h"
+#include "../../../min_allocator.h"
int main()
{
@@ -91,4 +92,40 @@ int main()
assert(*next(mo.begin(), 2) == V(3, 1));
}
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::map<int, double, C, A> m = mo;
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == V(1, 1));
+ assert(*next(mo.begin()) == V(2, 1));
+ assert(*next(mo.begin(), 2) == V(3, 1));
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.cons/copy_alloc.pass.cpp b/libcxx/test/containers/associative/map/map.cons/copy_alloc.pass.cpp
index 27b1c9710cc..849240408ab 100644
--- a/libcxx/test/containers/associative/map/map.cons/copy_alloc.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.cons/copy_alloc.pass.cpp
@@ -18,9 +18,11 @@
#include "../../../test_compare.h"
#include "../../../test_allocator.h"
+#include "../../../min_allocator.h"
int main()
{
+ {
typedef std::pair<const int, double> V;
V ar[] =
{
@@ -53,4 +55,41 @@ int main()
assert(*mo.begin() == V(1, 1));
assert(*next(mo.begin()) == V(2, 1));
assert(*next(mo.begin(), 2) == V(3, 1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::map<int, double, C, A> m(mo, A());
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == V(1, 1));
+ assert(*next(mo.begin()) == V(2, 1));
+ assert(*next(mo.begin(), 2) == V(3, 1));
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.cons/copy_assign.pass.cpp b/libcxx/test/containers/associative/map/map.cons/copy_assign.pass.cpp
index 7422ec99a90..fefb35ce712 100644
--- a/libcxx/test/containers/associative/map/map.cons/copy_assign.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.cons/copy_assign.pass.cpp
@@ -18,6 +18,7 @@
#include "../../../test_compare.h"
#include "../../../test_allocator.h"
+#include "../../../min_allocator.h"
int main()
{
@@ -91,4 +92,76 @@ int main()
assert(*next(mo.begin()) == V(2, 1));
assert(*next(mo.begin(), 2) == V(3, 1));
}
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2)
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A());
+ m = mo;
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == V(1, 1));
+ assert(*next(mo.begin()) == V(2, 1));
+ assert(*next(mo.begin(), 2) == V(3, 1));
+ }
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2)
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A());
+ m = mo;
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == V(1, 1));
+ assert(*next(mo.begin()) == V(2, 1));
+ assert(*next(mo.begin(), 2) == V(3, 1));
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.cons/default.pass.cpp b/libcxx/test/containers/associative/map/map.cons/default.pass.cpp
index 8b5397c3def..49fc223ffad 100644
--- a/libcxx/test/containers/associative/map/map.cons/default.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.cons/default.pass.cpp
@@ -16,9 +16,20 @@
#include <map>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
+ {
std::map<int, double> m;
assert(m.empty());
assert(m.begin() == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> m;
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.cons/default_recursive.pass.cpp b/libcxx/test/containers/associative/map/map.cons/default_recursive.pass.cpp
index 452746c87bb..8b393d3c91c 100644
--- a/libcxx/test/containers/associative/map/map.cons/default_recursive.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.cons/default_recursive.pass.cpp
@@ -19,7 +19,7 @@
struct X
{
- std::multimap<int, X> m;
+ std::map<int, X> m;
};
#endif
diff --git a/libcxx/test/containers/associative/map/map.cons/initializer_list.pass.cpp b/libcxx/test/containers/associative/map/map.cons/initializer_list.pass.cpp
index 4acf2dcab51..63820beea13 100644
--- a/libcxx/test/containers/associative/map/map.cons/initializer_list.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.cons/initializer_list.pass.cpp
@@ -16,9 +16,12 @@
#include <map>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
typedef std::pair<const int, double> V;
std::map<int, double> m =
{
@@ -37,5 +40,28 @@ int main()
assert(*m.begin() == V(1, 1));
assert(*next(m.begin()) == V(2, 1));
assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ std::map<int, double, std::less<int>, min_allocator<V>> m =
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ };
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}
diff --git a/libcxx/test/containers/associative/map/map.cons/initializer_list_compare.pass.cpp b/libcxx/test/containers/associative/map/map.cons/initializer_list_compare.pass.cpp
index 723a03f49d9..0c3bd23a635 100644
--- a/libcxx/test/containers/associative/map/map.cons/initializer_list_compare.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.cons/initializer_list_compare.pass.cpp
@@ -16,10 +16,12 @@
#include <map>
#include <cassert>
#include "../../../test_compare.h"
+#include "../../../min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
typedef std::pair<const int, double> V;
typedef test_compare<std::less<int> > C;
std::map<int, double, C> m({
@@ -39,5 +41,29 @@ int main()
assert(*next(m.begin()) == V(2, 1));
assert(*next(m.begin(), 2) == V(3, 1));
assert(m.key_comp() == C(3));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef test_compare<std::less<int> > C;
+ std::map<int, double, C, min_allocator<std::pair<const int, double>>> m({
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ }, C(3));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ assert(m.key_comp() == C(3));
+ }
+#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}
diff --git a/libcxx/test/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp b/libcxx/test/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp
index f6300de20b9..14e0eb3d4f7 100644
--- a/libcxx/test/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp
@@ -17,10 +17,12 @@
#include <cassert>
#include "../../../test_compare.h"
#include "../../../test_allocator.h"
+#include "../../../min_allocator.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
typedef std::pair<const int, double> V;
typedef test_compare<std::less<int> > C;
typedef test_allocator<std::pair<const int, double> > A;
@@ -42,5 +44,31 @@ int main()
assert(*next(m.begin(), 2) == V(3, 1));
assert(m.key_comp() == C(3));
assert(m.get_allocator() == A(6));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<std::pair<const int, double> > A;
+ std::map<int, double, C, A> m({
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ }, C(3), A());
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ assert(m.key_comp() == C(3));
+ assert(m.get_allocator() == A());
+ }
+#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}
diff --git a/libcxx/test/containers/associative/map/map.cons/iter_iter.pass.cpp b/libcxx/test/containers/associative/map/map.cons/iter_iter.pass.cpp
index 00d3d8a2766..d981ccff889 100644
--- a/libcxx/test/containers/associative/map/map.cons/iter_iter.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.cons/iter_iter.pass.cpp
@@ -17,8 +17,11 @@
#include <map>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
+ {
typedef std::pair<const int, double> V;
V ar[] =
{
@@ -38,4 +41,28 @@ int main()
assert(*m.begin() == V(1, 1));
assert(*next(m.begin()) == V(2, 1));
assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.cons/iter_iter_comp.pass.cpp b/libcxx/test/containers/associative/map/map.cons/iter_iter_comp.pass.cpp
index 6f851931ce9..0481de24ccd 100644
--- a/libcxx/test/containers/associative/map/map.cons/iter_iter_comp.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.cons/iter_iter_comp.pass.cpp
@@ -18,9 +18,11 @@
#include <cassert>
#include "../../../test_compare.h"
+#include "../../../min_allocator.h"
int main()
{
+ {
typedef std::pair<const int, double> V;
V ar[] =
{
@@ -42,4 +44,30 @@ int main()
assert(*m.begin() == V(1, 1));
assert(*next(m.begin()) == V(2, 1));
assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ std::map<int, double, C, min_allocator<std::pair<const int, double>>> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp b/libcxx/test/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp
index abee6d9f0b0..8fabdcc087d 100644
--- a/libcxx/test/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp
@@ -20,9 +20,11 @@
#include "../../../test_compare.h"
#include "../../../test_allocator.h"
+#include "../../../min_allocator.h"
int main()
{
+ {
typedef std::pair<const int, double> V;
V ar[] =
{
@@ -46,4 +48,32 @@ int main()
assert(*m.begin() == V(1, 1));
assert(*next(m.begin()) == V(2, 1));
assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.cons/move.pass.cpp b/libcxx/test/containers/associative/map/map.cons/move.pass.cpp
index b86dd6e382c..323a26548e9 100644
--- a/libcxx/test/containers/associative/map/map.cons/move.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.cons/move.pass.cpp
@@ -18,6 +18,7 @@
#include "../../../test_compare.h"
#include "../../../test_allocator.h"
+#include "../../../min_allocator.h"
int main()
{
@@ -68,5 +69,52 @@ int main()
assert(mo.size() == 0);
assert(distance(mo.begin(), mo.end()) == 0);
}
+#if __cplusplus >= 201103L
+ {
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::map<int, double, C, A> mo(C(5), A());
+ std::map<int, double, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 0);
+ assert(distance(m.begin(), m.end()) == 0);
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+ {
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::map<int, double, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
diff --git a/libcxx/test/containers/associative/map/map.cons/move_alloc.pass.cpp b/libcxx/test/containers/associative/map/map.cons/move_alloc.pass.cpp
index c9675dbd645..2bb2c061258 100644
--- a/libcxx/test/containers/associative/map/map.cons/move_alloc.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.cons/move_alloc.pass.cpp
@@ -19,6 +19,7 @@
#include "../../../MoveOnly.h"
#include "../../../test_compare.h"
#include "../../../test_allocator.h"
+#include "../../../min_allocator.h"
int main()
{
@@ -140,5 +141,46 @@ int main()
assert(m3.key_comp() == C(5));
assert(m1.empty());
}
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef min_allocator<VC> A;
+ typedef std::map<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A());
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A());
+ M m3(std::move(m1), A());
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A());
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
diff --git a/libcxx/test/containers/associative/map/map.cons/move_assign.pass.cpp b/libcxx/test/containers/associative/map/map.cons/move_assign.pass.cpp
index e8b9a88d97e..2e6ede7bec7 100644
--- a/libcxx/test/containers/associative/map/map.cons/move_assign.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.cons/move_assign.pass.cpp
@@ -19,6 +19,7 @@
#include "../../../MoveOnly.h"
#include "../../../test_compare.h"
#include "../../../test_allocator.h"
+#include "../../../min_allocator.h"
int main()
{
@@ -143,5 +144,47 @@ int main()
assert(m3.key_comp() == C(5));
assert(m1.empty());
}
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef min_allocator<VC> A;
+ typedef std::map<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A());
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A());
+ M m3(C(3), A());
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A());
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
diff --git a/libcxx/test/containers/associative/map/map.modifiers/clear.pass.cpp b/libcxx/test/containers/associative/map/map.modifiers/clear.pass.cpp
index a181e632e88..77f50badfef 100644
--- a/libcxx/test/containers/associative/map/map.modifiers/clear.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.modifiers/clear.pass.cpp
@@ -16,6 +16,8 @@
#include <map>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
{
@@ -37,4 +39,25 @@ int main()
m.clear();
assert(m.size() == 0);
}
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ m.clear();
+ assert(m.size() == 0);
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.modifiers/emplace.pass.cpp b/libcxx/test/containers/associative/map/map.modifiers/emplace.pass.cpp
index 4eb7e9f832a..3ade69db72e 100644
--- a/libcxx/test/containers/associative/map/map.modifiers/emplace.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.modifiers/emplace.pass.cpp
@@ -20,6 +20,7 @@
#include "../../../Emplaceable.h"
#include "../../../DefaultOnly.h"
+#include "../../../min_allocator.h"
int main()
{
@@ -88,5 +89,71 @@ int main()
assert(m.begin()->first == 2);
assert(m.begin()->second == 3.5);
}
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace();
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 0);
+ assert(m.begin()->second == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+ r = m.emplace(1);
+ assert(r.second);
+ assert(r.first == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ r = m.emplace(1);
+ assert(!r.second);
+ assert(r.first == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::map<int, Emplaceable, std::less<int>, min_allocator<std::pair<const int, Emplaceable>>> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.emplace(2);
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == Emplaceable());
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(!r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ }
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.emplace(M::value_type(2, 3.5));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 3.5);
+ }
+#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
diff --git a/libcxx/test/containers/associative/map/map.modifiers/emplace_hint.pass.cpp b/libcxx/test/containers/associative/map/map.modifiers/emplace_hint.pass.cpp
index 2bc225e28a7..e1eb586d487 100644
--- a/libcxx/test/containers/associative/map/map.modifiers/emplace_hint.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.modifiers/emplace_hint.pass.cpp
@@ -19,6 +19,7 @@
#include "../../../Emplaceable.h"
#include "../../../DefaultOnly.h"
+#include "../../../min_allocator.h"
int main()
{
@@ -82,5 +83,66 @@ int main()
assert(m.begin()->first == 2);
assert(m.begin()->second == 3.5);
}
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M;
+ typedef M::iterator R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace_hint(m.end());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 0);
+ assert(m.begin()->second == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+ r = m.emplace_hint(m.end(), 1);
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ r = m.emplace_hint(m.end(), 1);
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::map<int, Emplaceable, std::less<int>, min_allocator<std::pair<const int, Emplaceable>>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.end(), 2);
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == Emplaceable());
+ r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ }
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.end(), M::value_type(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 3.5);
+ }
+#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
diff --git a/libcxx/test/containers/associative/map/map.modifiers/erase_iter.pass.cpp b/libcxx/test/containers/associative/map/map.modifiers/erase_iter.pass.cpp
index caf16472e29..086096b7c8b 100644
--- a/libcxx/test/containers/associative/map/map.modifiers/erase_iter.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.modifiers/erase_iter.pass.cpp
@@ -16,6 +16,8 @@
#include <map>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
{
@@ -124,4 +126,112 @@ int main()
assert(i == m.begin());
assert(i == m.end());
}
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ typedef M::iterator I;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(next(m.cbegin(), 3));
+ assert(m.size() == 7);
+ assert(i == next(m.begin(), 3));
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1.5);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 2.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 3.5);
+ assert(next(m.begin(), 3)->first == 5);
+ assert(next(m.begin(), 3)->second == 5.5);
+ assert(next(m.begin(), 4)->first == 6);
+ assert(next(m.begin(), 4)->second == 6.5);
+ assert(next(m.begin(), 5)->first == 7);
+ assert(next(m.begin(), 5)->second == 7.5);
+ assert(next(m.begin(), 6)->first == 8);
+ assert(next(m.begin(), 6)->second == 8.5);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 6);
+ assert(i == m.begin());
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 3);
+ assert(next(m.begin())->second == 3.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+ assert(next(m.begin(), 5)->first == 8);
+ assert(next(m.begin(), 5)->second == 8.5);
+
+ i = m.erase(next(m.cbegin(), 5));
+ assert(m.size() == 5);
+ assert(i == m.end());
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 3);
+ assert(next(m.begin())->second == 3.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+
+ i = m.erase(next(m.cbegin(), 1));
+ assert(m.size() == 4);
+ assert(i == next(m.begin()));
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+ assert(next(m.begin(), 2)->first == 6);
+ assert(next(m.begin(), 2)->second == 6.5);
+ assert(next(m.begin(), 3)->first == 7);
+ assert(next(m.begin(), 3)->second == 7.5);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 3);
+ assert(i == next(m.begin(), 2));
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+ assert(next(m.begin(), 2)->first == 7);
+ assert(next(m.begin(), 2)->second == 7.5);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 2));
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 1);
+ assert(i == next(m.begin(), 0));
+ assert(m.begin()->first == 5);
+ assert(m.begin()->second == 5.5);
+
+ i = m.erase(m.cbegin());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp b/libcxx/test/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp
index b595d8a0736..6589ace8ff1 100644
--- a/libcxx/test/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp
@@ -16,6 +16,8 @@
#include <map>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
{
@@ -84,4 +86,72 @@ int main()
assert(i == m.begin());
assert(i == m.end());
}
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ typedef M::iterator I;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(m.cbegin(), m.cbegin());
+ assert(m.size() == 8);
+ assert(i == m.begin());
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1.5);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 2.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 3.5);
+ assert(next(m.begin(), 3)->first == 4);
+ assert(next(m.begin(), 3)->second == 4.5);
+ assert(next(m.begin(), 4)->first == 5);
+ assert(next(m.begin(), 4)->second == 5.5);
+ assert(next(m.begin(), 5)->first == 6);
+ assert(next(m.begin(), 5)->second == 6.5);
+ assert(next(m.begin(), 6)->first == 7);
+ assert(next(m.begin(), 6)->second == 7.5);
+ assert(next(m.begin(), 7)->first == 8);
+ assert(next(m.begin(), 7)->second == 8.5);
+
+ i = m.erase(m.cbegin(), next(m.cbegin(), 2));
+ assert(m.size() == 6);
+ assert(i == m.begin());
+ assert(next(m.begin(), 0)->first == 3);
+ assert(next(m.begin(), 0)->second == 3.5);
+ assert(next(m.begin(), 1)->first == 4);
+ assert(next(m.begin(), 1)->second == 4.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+ assert(next(m.begin(), 5)->first == 8);
+ assert(next(m.begin(), 5)->second == 8.5);
+
+ i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 6));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 2));
+ assert(next(m.begin(), 0)->first == 3);
+ assert(next(m.begin(), 0)->second == 3.5);
+ assert(next(m.begin(), 1)->first == 4);
+ assert(next(m.begin(), 1)->second == 4.5);
+
+ i = m.erase(m.cbegin(), m.cend());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.modifiers/erase_key.pass.cpp b/libcxx/test/containers/associative/map/map.modifiers/erase_key.pass.cpp
index e78a00ff74e..4a93173a704 100644
--- a/libcxx/test/containers/associative/map/map.modifiers/erase_key.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.modifiers/erase_key.pass.cpp
@@ -16,6 +16,8 @@
#include <map>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
{
@@ -143,4 +145,131 @@ int main()
assert(m.size() == 0);
assert(s == 1);
}
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ typedef M::size_type R;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ R s = m.erase(9);
+ assert(s == 0);
+ assert(m.size() == 8);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1.5);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 2.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 3.5);
+ assert(next(m.begin(), 3)->first == 4);
+ assert(next(m.begin(), 3)->second == 4.5);
+ assert(next(m.begin(), 4)->first == 5);
+ assert(next(m.begin(), 4)->second == 5.5);
+ assert(next(m.begin(), 5)->first == 6);
+ assert(next(m.begin(), 5)->second == 6.5);
+ assert(next(m.begin(), 6)->first == 7);
+ assert(next(m.begin(), 6)->second == 7.5);
+ assert(next(m.begin(), 7)->first == 8);
+ assert(next(m.begin(), 7)->second == 8.5);
+
+ s = m.erase(4);
+ assert(m.size() == 7);
+ assert(s == 1);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1.5);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 2.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 3.5);
+ assert(next(m.begin(), 3)->first == 5);
+ assert(next(m.begin(), 3)->second == 5.5);
+ assert(next(m.begin(), 4)->first == 6);
+ assert(next(m.begin(), 4)->second == 6.5);
+ assert(next(m.begin(), 5)->first == 7);
+ assert(next(m.begin(), 5)->second == 7.5);
+ assert(next(m.begin(), 6)->first == 8);
+ assert(next(m.begin(), 6)->second == 8.5);
+
+ s = m.erase(1);
+ assert(m.size() == 6);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 3);
+ assert(next(m.begin())->second == 3.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+ assert(next(m.begin(), 5)->first == 8);
+ assert(next(m.begin(), 5)->second == 8.5);
+
+ s = m.erase(8);
+ assert(m.size() == 5);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 3);
+ assert(next(m.begin())->second == 3.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+
+ s = m.erase(3);
+ assert(m.size() == 4);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+ assert(next(m.begin(), 2)->first == 6);
+ assert(next(m.begin(), 2)->second == 6.5);
+ assert(next(m.begin(), 3)->first == 7);
+ assert(next(m.begin(), 3)->second == 7.5);
+
+ s = m.erase(6);
+ assert(m.size() == 3);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+ assert(next(m.begin(), 2)->first == 7);
+ assert(next(m.begin(), 2)->second == 7.5);
+
+ s = m.erase(7);
+ assert(m.size() == 2);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+
+ s = m.erase(2);
+ assert(m.size() == 1);
+ assert(s == 1);
+ assert(m.begin()->first == 5);
+ assert(m.begin()->second == 5.5);
+
+ s = m.erase(5);
+ assert(m.size() == 0);
+ assert(s == 1);
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.modifiers/insert_cv.pass.cpp b/libcxx/test/containers/associative/map/map.modifiers/insert_cv.pass.cpp
index f405c4c3765..24d3f84ea30 100644
--- a/libcxx/test/containers/associative/map/map.modifiers/insert_cv.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.modifiers/insert_cv.pass.cpp
@@ -16,6 +16,8 @@
#include <map>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
{
@@ -50,4 +52,38 @@ int main()
assert(r.first->first == 3);
assert(r.first->second == 3.5);
}
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.insert(M::value_type(2, 2.5));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(r.first->first == 2);
+ assert(r.first->second == 2.5);
+
+ r = m.insert(M::value_type(1, 1.5));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(r.first->first == 1);
+ assert(r.first->second == 1.5);
+
+ r = m.insert(M::value_type(3, 3.5));
+ assert(r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3.5);
+
+ r = m.insert(M::value_type(3, 3.5));
+ assert(!r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3.5);
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp b/libcxx/test/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp
index 66714d53eb5..bc7e760fad0 100644
--- a/libcxx/test/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp
@@ -16,9 +16,12 @@
#include <map>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
typedef std::pair<const int, double> V;
std::map<int, double> m =
{
@@ -39,5 +42,30 @@ int main()
assert(*m.begin() == V(1, 1));
assert(*next(m.begin()) == V(2, 1));
assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ std::map<int, double, std::less<int>, min_allocator<V>> m =
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ };
+ m.insert({
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ });
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}
diff --git a/libcxx/test/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp b/libcxx/test/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp
index 105b4564dcd..43ca35a099f 100644
--- a/libcxx/test/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp
@@ -16,6 +16,8 @@
#include <map>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
{
@@ -46,4 +48,34 @@ int main()
assert(r->first == 3);
assert(r->second == 3.5);
}
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.end(), M::value_type(2, 2.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2.5);
+
+ r = m.insert(m.end(), M::value_type(1, 1.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1.5);
+
+ r = m.insert(m.end(), M::value_type(3, 3.5));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
+
+ r = m.insert(m.end(), M::value_type(3, 3.5));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp b/libcxx/test/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp
index 307e3e42f39..d1acdf2b826 100644
--- a/libcxx/test/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp
@@ -18,6 +18,7 @@
#include <cassert>
#include "test_iterators.h"
+#include "../../../min_allocator.h"
int main()
{
@@ -46,4 +47,31 @@ int main()
assert(next(m.begin(), 2)->first == 3);
assert(next(m.begin(), 2)->second == 1);
}
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ P ar[] =
+ {
+ P(1, 1),
+ P(1, 1.5),
+ P(1, 2),
+ P(2, 1),
+ P(2, 1.5),
+ P(2, 2),
+ P(3, 1),
+ P(3, 1.5),
+ P(3, 2),
+ };
+ M m;
+ m.insert(input_iterator<P*>(ar), input_iterator<P*>(ar + sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 3);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 1);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 1);
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp b/libcxx/test/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp
index 620c0159033..e84a82b609a 100644
--- a/libcxx/test/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp
@@ -18,6 +18,7 @@
#include <cassert>
#include "../../../MoveOnly.h"
+#include "../../../min_allocator.h"
int main()
{
@@ -51,5 +52,36 @@ int main()
assert(r->first == 3);
assert(r->second == 3);
}
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M;
+ typedef std::pair<int, MoveOnly> P;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.end(), P(2, 2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2);
+
+ r = m.insert(m.end(), P(1, 1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1);
+
+ r = m.insert(m.end(), P(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = m.insert(m.end(), P(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3);
+ }
+#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
diff --git a/libcxx/test/containers/associative/map/map.modifiers/insert_rv.pass.cpp b/libcxx/test/containers/associative/map/map.modifiers/insert_rv.pass.cpp
index b95202b32f8..c5724c42980 100644
--- a/libcxx/test/containers/associative/map/map.modifiers/insert_rv.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.modifiers/insert_rv.pass.cpp
@@ -18,6 +18,7 @@
#include <cassert>
#include "../../../MoveOnly.h"
+#include "../../../min_allocator.h"
int main()
{
@@ -54,5 +55,39 @@ int main()
assert(r.first->first == 3);
assert(r.first->second == 3);
}
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.insert(M::value_type(2, 2));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(r.first->first == 2);
+ assert(r.first->second == 2);
+
+ r = m.insert(M::value_type(1, 1));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(r.first->first == 1);
+ assert(r.first->second == 1);
+
+ r = m.insert(M::value_type(3, 3));
+ assert(r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3);
+
+ r = m.insert(M::value_type(3, 3));
+ assert(!r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3);
+ }
+#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
diff --git a/libcxx/test/containers/associative/map/map.ops/count.pass.cpp b/libcxx/test/containers/associative/map/map.ops/count.pass.cpp
index 427feff970b..70eadac3f8f 100644
--- a/libcxx/test/containers/associative/map/map.ops/count.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.ops/count.pass.cpp
@@ -16,8 +16,11 @@
#include <map>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
+ {
typedef std::pair<const int, double> V;
typedef std::map<int, double> M;
{
@@ -53,4 +56,44 @@ int main()
r = m.count(4);
assert(r == 0);
}
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+ {
+ typedef M::size_type R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(5);
+ assert(r == 1);
+ r = m.count(6);
+ assert(r == 1);
+ r = m.count(7);
+ assert(r == 1);
+ r = m.count(8);
+ assert(r == 1);
+ r = m.count(9);
+ assert(r == 1);
+ r = m.count(10);
+ assert(r == 1);
+ r = m.count(11);
+ assert(r == 1);
+ r = m.count(12);
+ assert(r == 1);
+ r = m.count(4);
+ assert(r == 0);
+ }
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.ops/equal_range.pass.cpp b/libcxx/test/containers/associative/map/map.ops/equal_range.pass.cpp
index 057ef6a4458..dc0d09760a9 100644
--- a/libcxx/test/containers/associative/map/map.ops/equal_range.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.ops/equal_range.pass.cpp
@@ -17,8 +17,11 @@
#include <map>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
+ {
typedef std::pair<const int, double> V;
typedef std::map<int, double> M;
{
@@ -153,4 +156,143 @@ int main()
assert(r.first == next(m.begin(), 8));
assert(r.second == next(m.begin(), 8));
}
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+ {
+ typedef std::pair<M::iterator, M::iterator> R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(11);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(13);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(15);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(17);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(19);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(12);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(14);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(16);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(18);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(20);
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+ }
+ {
+ typedef std::pair<M::const_iterator, M::const_iterator> R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(11);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(13);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(15);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(17);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(19);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(12);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(14);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(16);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(18);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(20);
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+ }
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.ops/find.pass.cpp b/libcxx/test/containers/associative/map/map.ops/find.pass.cpp
index afebf129474..a368dc5e7aa 100644
--- a/libcxx/test/containers/associative/map/map.ops/find.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.ops/find.pass.cpp
@@ -17,8 +17,11 @@
#include <map>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
+ {
typedef std::pair<const int, double> V;
typedef std::map<int, double> M;
{
@@ -87,4 +90,77 @@ int main()
r = m.find(4);
assert(r == next(m.begin(), 8));
}
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.ops/lower_bound.pass.cpp b/libcxx/test/containers/associative/map/map.ops/lower_bound.pass.cpp
index f2f03cf37fe..a1b8e5b3c2e 100644
--- a/libcxx/test/containers/associative/map/map.ops/lower_bound.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.ops/lower_bound.pass.cpp
@@ -17,8 +17,11 @@
#include <map>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
+ {
typedef std::pair<const int, double> V;
typedef std::map<int, double> M;
{
@@ -119,4 +122,109 @@ int main()
r = m.lower_bound(20);
assert(r == next(m.begin(), 8));
}
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.ops/upper_bound.pass.cpp b/libcxx/test/containers/associative/map/map.ops/upper_bound.pass.cpp
index 0d97e70ee4a..eee08aee31b 100644
--- a/libcxx/test/containers/associative/map/map.ops/upper_bound.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.ops/upper_bound.pass.cpp
@@ -17,8 +17,11 @@
#include <map>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
+ {
typedef std::pair<const int, double> V;
typedef std::map<int, double> M;
{
@@ -119,4 +122,109 @@ int main()
r = m.upper_bound(20);
assert(r == next(m.begin(), 8));
}
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.special/member_swap.pass.cpp b/libcxx/test/containers/associative/map/map.special/member_swap.pass.cpp
index 84513450e50..af5922526a0 100644
--- a/libcxx/test/containers/associative/map/map.special/member_swap.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.special/member_swap.pass.cpp
@@ -16,8 +16,11 @@
#include <map>
#include <cassert>
+#include "../../../min_allocator.h"
+
int main()
{
+ {
typedef std::pair<const int, double> V;
typedef std::map<int, double> M;
{
@@ -104,4 +107,95 @@ int main()
assert(m1 == m2_save);
assert(m2 == m1_save);
}
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/map.special/non_member_swap.pass.cpp b/libcxx/test/containers/associative/map/map.special/non_member_swap.pass.cpp
index ef67892a7a7..e474a4661bb 100644
--- a/libcxx/test/containers/associative/map/map.special/non_member_swap.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.special/non_member_swap.pass.cpp
@@ -19,9 +19,11 @@
#include <cassert>
#include "../../../test_allocator.h"
#include "../../../test_compare.h"
+#include "../../../min_allocator.h"
int main()
{
+ {
typedef std::pair<const int, double> V;
typedef std::map<int, double> M;
{
@@ -176,4 +178,129 @@ int main()
assert(m2.key_comp() == C(1));
assert(m2.get_allocator() == A(1));
}
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ typedef min_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ typedef std::map<int, double, C, A> M;
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A());
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A());
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ assert(m1.key_comp() == C(2));
+ assert(m1.get_allocator() == A());
+ assert(m2.key_comp() == C(1));
+ assert(m2.get_allocator() == A());
+ }
+ }
+#endif
}
diff --git a/libcxx/test/containers/associative/map/types.pass.cpp b/libcxx/test/containers/associative/map/types.pass.cpp
index 313b7bdbbac..aca81dfb964 100644
--- a/libcxx/test/containers/associative/map/types.pass.cpp
+++ b/libcxx/test/containers/associative/map/types.pass.cpp
@@ -32,8 +32,11 @@
#include <map>
#include <type_traits>
+#include "../../min_allocator.h"
+
int main()
{
+ {
static_assert((std::is_same<std::map<int, double>::key_type, int>::value), "");
static_assert((std::is_same<std::map<int, double>::mapped_type, double>::value), "");
static_assert((std::is_same<std::map<int, double>::value_type, std::pair<const int, double> >::value), "");
@@ -45,4 +48,20 @@ int main()
static_assert((std::is_same<std::map<int, double>::const_pointer, const std::pair<const int, double>*>::value), "");
static_assert((std::is_same<std::map<int, double>::size_type, std::size_t>::value), "");
static_assert((std::is_same<std::map<int, double>::difference_type, std::ptrdiff_t>::value), "");
+ }
+#if __cplusplus >= 201103L
+ {
+ static_assert((std::is_same<std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::key_type, int>::value), "");
+ static_assert((std::is_same<std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::mapped_type, double>::value), "");
+ static_assert((std::is_same<std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::value_type, std::pair<const int, double> >::value), "");
+ static_assert((std::is_same<std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::key_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::allocator_type, min_allocator<std::pair<const int, double> > >::value), "");
+ static_assert((std::is_same<std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::reference, std::pair<const int, double>&>::value), "");
+ static_assert((std::is_same<std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::const_reference, const std::pair<const int, double>&>::value), "");
+ static_assert((std::is_same<std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::pointer, min_pointer<std::pair<const int, double>>>::value), "");
+ static_assert((std::is_same<std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::const_pointer, min_pointer<const std::pair<const int, double>>>::value), "");
+ static_assert((std::is_same<std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>>::difference_type, std::ptrdiff_t>::value), "");
+ }
+#endif
}
OpenPOWER on IntegriCloud