summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std')
-rw-r--r--libcxx/test/std/containers/associative/map/map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp1
-rw-r--r--libcxx/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp103
-rw-r--r--libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp91
-rw-r--r--libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp96
-rw-r--r--libcxx/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp108
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_allocator_requirements.pass.cpp1
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp94
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp90
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp96
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp91
-rw-r--r--libcxx/test/std/containers/map_allocator_requirement_test_templates.h195
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp1
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp103
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp33
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp36
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_allocator_requirements.pass.cpp1
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp33
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp32
18 files changed, 672 insertions, 533 deletions
diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp
index 9eae6281042..d98047d02e7 100644
--- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp
+++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp
@@ -25,6 +25,7 @@
int main()
{
testMapInsert<TCT::map<> >();
+ testMapInsertHint<TCT::map<> >();
testMapEmplace<TCT::map<> >();
testMapEmplaceHint<TCT::map<> >();
}
diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp
index 3d28242fd32..e2ffcba375f 100644
--- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp
+++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp
@@ -16,74 +16,57 @@
#include <map>
#include <cassert>
+#include "test_macros.h"
#include "min_allocator.h"
-int main()
+template <class Container>
+void do_insert_cv_test()
{
- {
- typedef std::map<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);
+ typedef Container M;
+ typedef std::pair<typename M::iterator, bool> R;
+ typedef typename M::value_type VT;
+ M m;
- 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);
+ const VT v1(2, 2.5);
+ R r = m.insert(v1);
+ 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(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);
- }
-#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);
+ const VT v2(1, 1.5);
+ r = m.insert(v2);
+ 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(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);
+ const VT v3(3, 3.5);
+ r = m.insert(v3);
+ 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);
+ const VT v4(3, 4.5);
+ r = m.insert(v4);
+ 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);
+int main()
+{
+ do_insert_cv_test<std::map<int, double> >();
+#if TEST_STD_VER >= 11
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ do_insert_cv_test<M>();
}
#endif
}
diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp
index 278db4631a8..0c7e124e0d1 100644
--- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp
+++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp
@@ -16,66 +16,53 @@
#include <map>
#include <cassert>
+#include "test_macros.h"
#include "min_allocator.h"
-int main()
+template <class Container>
+void do_insert_iter_cv_test()
{
- {
- typedef std::map<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);
+ typedef Container M;
+ typedef typename M::iterator R;
+ typedef typename M::value_type VT;
- 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);
+ M m;
+ const VT v1(2, 2.5);
+ R r = m.insert(m.end(), v1);
+ 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(3, 3.5));
- assert(r == prev(m.end()));
- assert(m.size() == 3);
- 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);
+ const VT v2(1, 1.5);
+ r = m.insert(m.end(), v2);
+ 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(1, 1.5));
- assert(r == m.begin());
- assert(m.size() == 2);
- assert(r->first == 1);
- assert(r->second == 1.5);
+ const VT v3(3, 3.5);
+ r = m.insert(m.end(), v3);
+ 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);
+ const VT v4(3, 4.5);
+ r = m.insert(m.end(), v4);
+ 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);
+int main()
+{
+ do_insert_iter_cv_test<std::map<int, double> >();
+#if TEST_STD_VER >= 11
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ do_insert_iter_cv_test<M>();
}
#endif
}
diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp
index 9db1e5c7073..3edb9c06e7c 100644
--- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp
+++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <map>
// class map
@@ -21,70 +23,49 @@
#include "min_allocator.h"
#include "test_macros.h"
-int main()
+template <class Container, class Pair>
+void do_insert_iter_rv_test()
{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- {
- typedef std::map<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);
+ typedef Container M;
+ typedef Pair P;
+ typedef typename 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(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);
+
+ r = m.insert(m.end(), P(3, 4));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3);
+}
+int main()
+{
+ do_insert_iter_rv_test<std::map<int, MoveOnly>, std::pair<int, MoveOnly>>();
+ do_insert_iter_rv_test<std::map<int, MoveOnly>, std::pair<const int, MoveOnly>>();
- 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);
- }
-#if TEST_STD_VER >= 11
{
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);
+ typedef std::pair<const int, MoveOnly> CP;
+ do_insert_iter_rv_test<M, P>();
+ do_insert_iter_rv_test<M, CP>();
}
-#endif
-#if TEST_STD_VER > 14
{
typedef std::map<int, MoveOnly> M;
typedef M::iterator R;
@@ -113,6 +94,5 @@ int main()
assert(r->first == 3);
assert(r->second == 3);
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#endif
+
}
diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp
index 23eb84d687f..503d9291076 100644
--- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp
+++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <map>
// class map
@@ -22,76 +24,54 @@
#include "min_allocator.h"
#include "test_macros.h"
-int main()
+template <class Container, class Pair>
+void do_insert_rv_test()
{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- {
- typedef std::map<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);
+ typedef Container M;
+ typedef Pair P;
+ typedef std::pair<typename M::iterator, bool> R;
+ M m;
+ R r = m.insert(P(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(P(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(P(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);
- }
-#if TEST_STD_VER >= 11
- {
- 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(P(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);
+int main()
+{
+ do_insert_rv_test<std::map<int, MoveOnly>, std::pair<int, MoveOnly>>();
+ do_insert_rv_test<std::map<int, MoveOnly>, std::pair<const int, MoveOnly>>();
- 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);
+ {
+ typedef std::map<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M;
+ typedef std::pair<int, MoveOnly> P;
+ typedef std::pair<const int, MoveOnly> CP;
+ do_insert_rv_test<M, P>();
+ do_insert_rv_test<M, CP>();
}
-#endif
-#if TEST_STD_VER > 14
{
typedef std::map<int, MoveOnly> M;
typedef std::pair<M::iterator, bool> R;
@@ -124,6 +104,4 @@ int main()
assert(r.first->first == 3);
assert(r.first->second == 3);
}
-#endif
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_allocator_requirements.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_allocator_requirements.pass.cpp
index d421de31767..225bf67bb1f 100644
--- a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_allocator_requirements.pass.cpp
+++ b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_allocator_requirements.pass.cpp
@@ -24,4 +24,5 @@
int main()
{
testMultimapInsert<TCT::multimap<> >();
+ testMultimapInsertHint<TCT::multimap<> >();
}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp
index d9afc9d0fdf..53874311c78 100644
--- a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp
+++ b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp
@@ -16,66 +16,54 @@
#include <map>
#include <cassert>
+#include "test_macros.h"
#include "min_allocator.h"
-int main()
-{
- {
- typedef std::multimap<int, double> M;
- typedef M::iterator R;
- M m;
- R r = m.insert(M::value_type(2, 2.5));
- assert(r == m.begin());
- assert(m.size() == 1);
- assert(r->first == 2);
- assert(r->second == 2.5);
+template <class Container>
+void do_insert_test() {
+ typedef Container M;
+ typedef typename M::iterator R;
+ typedef typename M::value_type VT;
+ M m;
+ const VT v1(2, 2.5);
+ R r = m.insert(v1);
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2.5);
- r = m.insert(M::value_type(1, 1.5));
- assert(r == m.begin());
- assert(m.size() == 2);
- assert(r->first == 1);
- assert(r->second == 1.5);
+ const VT v2(1, 1.5);
+ r = m.insert(v2);
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1.5);
- r = m.insert(M::value_type(3, 3.5));
- assert(r == prev(m.end()));
- assert(m.size() == 3);
- assert(r->first == 3);
- assert(r->second == 3.5);
+ const VT v3(3, 3.5);
+ r = m.insert(v3);
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
- r = m.insert(M::value_type(3, 3.5));
- assert(r == prev(m.end()));
- assert(m.size() == 4);
- assert(r->first == 3);
- assert(r->second == 3.5);
+ const VT v4(3, 3.5);
+ r = m.insert(v4);
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
+}
+
+int main()
+{
+ {
+ typedef std::multimap<int, double> Container;
+ do_insert_test<Container>();
}
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
{
- typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
- typedef M::iterator R;
- M m;
- R r = m.insert(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::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::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::value_type(3, 3.5));
- assert(r == prev(m.end()));
- assert(m.size() == 4);
- assert(r->first == 3);
- assert(r->second == 3.5);
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> Container;
+ do_insert_test<Container>();
}
#endif
}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp
index b83c802c04c..05e1096cb54 100644
--- a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp
+++ b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp
@@ -16,66 +16,52 @@
#include <map>
#include <cassert>
+#include "test_macros.h"
#include "min_allocator.h"
-int main()
+template <class Container>
+void do_insert_hint_test()
{
- {
- typedef std::multimap<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);
+ typedef Container M;
+ typedef typename M::iterator R;
+ typedef typename M::value_type VT;
+ M m;
+ const VT v1(2, 2.5);
+ R r = m.insert(m.end(), v1);
+ 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);
+ const VT v2(1, 1.5);
+ r = m.insert(m.end(), v2);
+ 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);
+ const VT v3(3, 3.5);
+ r = m.insert(m.end(), v3);
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
- r = m.insert(prev(m.end()), M::value_type(3, 4.5));
- assert(r == prev(m.end(), 2));
- assert(m.size() == 4);
- assert(r->first == 3);
- assert(r->second == 4.5);
- }
-#if __cplusplus >= 201103L
+ const VT v4(3, 4.5);
+ r = m.insert(prev(m.end()), v4);
+ assert(r == prev(m.end(), 2));
+ assert(m.size() == 4);
+ assert(r->first == 3);
+ assert(r->second == 4.5);
+}
+
+int main()
+{
+ do_insert_hint_test<std::multimap<int, double> >();
+#if TEST_STD_VER >= 11
{
typedef std::multimap<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(prev(m.end()), M::value_type(3, 4.5));
- assert(r == prev(m.end(), 2));
- assert(m.size() == 4);
- assert(r->first == 3);
- assert(r->second == 4.5);
+ do_insert_hint_test<M>();
}
#endif
}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp
index 7035de83f99..47e0d371bb4 100644
--- a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp
+++ b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <map>
// class multimap
@@ -21,73 +23,53 @@
#include "min_allocator.h"
#include "test_macros.h"
-int main()
+template <class Container, class Pair>
+void do_insert_rv_test()
{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- {
- typedef std::multimap<int, MoveOnly> M;
- typedef std::pair<int, MoveOnly> P;
- typedef M::iterator R;
- M m;
- R r = m.insert(m.cend(), P(2, 2));
- assert(r == m.begin());
- assert(m.size() == 1);
- assert(r->first == 2);
- assert(r->second == 2);
+ typedef Container M;
+ typedef Pair P;
+ typedef typename M::iterator R;
+ M m;
+ R r = m.insert(m.cend(), P(2, 2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2);
- r = m.insert(m.cend(), P(1, 1));
- assert(r == m.begin());
- assert(m.size() == 2);
- assert(r->first == 1);
- assert(r->second == 1);
+ r = m.insert(m.cend(), P(1, 1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1);
- r = m.insert(m.cend(), P(3, 3));
- assert(r == prev(m.end()));
- assert(m.size() == 3);
- assert(r->first == 3);
- assert(r->second == 3);
+ r = m.insert(m.cend(), P(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = m.insert(m.cend(), P(3, 2));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(r->first == 3);
+ assert(r->second == 2);
+}
+
+int main()
+{
+ do_insert_rv_test<std::multimap<int, MoveOnly>, std::pair<int, MoveOnly> >();
+ do_insert_rv_test<std::multimap<int, MoveOnly>, std::pair<const int, MoveOnly> >();
- r = m.insert(m.cend(), P(3, 2));
- assert(r == prev(m.end()));
- assert(m.size() == 4);
- assert(r->first == 3);
- assert(r->second == 2);
- }
-#if TEST_STD_VER >= 11
{
typedef std::multimap<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.cend(), P(2, 2));
- assert(r == m.begin());
- assert(m.size() == 1);
- assert(r->first == 2);
- assert(r->second == 2);
+ typedef std::pair<const int, MoveOnly> CP;
+ do_insert_rv_test<M, P>();
+ do_insert_rv_test<M, CP>();
- r = m.insert(m.cend(), P(1, 1));
- assert(r == m.begin());
- assert(m.size() == 2);
- assert(r->first == 1);
- assert(r->second == 1);
-
- r = m.insert(m.cend(), P(3, 3));
- assert(r == prev(m.end()));
- assert(m.size() == 3);
- assert(r->first == 3);
- assert(r->second == 3);
-
- r = m.insert(m.cend(), P(3, 2));
- assert(r == prev(m.end()));
- assert(m.size() == 4);
- assert(r->first == 3);
- assert(r->second == 2);
}
-#endif
-#if TEST_STD_VER > 14
{
typedef std::multimap<int, MoveOnly> M;
- typedef std::pair<int, MoveOnly> P;
typedef M::iterator R;
M m;
R r = m.insert(m.cend(), {2, MoveOnly(2)});
@@ -114,6 +96,4 @@ int main()
assert(r->first == 3);
assert(r->second == 2);
}
-#endif
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp
index 825e304f65a..022de873f7f 100644
--- a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp
+++ b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <map>
// class multimap
@@ -21,68 +23,45 @@
#include "min_allocator.h"
#include "test_macros.h"
-int main()
+template <class Container>
+void do_insert_rv_test()
{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- {
- typedef std::multimap<int, MoveOnly> M;
- typedef M::iterator R;
- M m;
- R r = m.insert(M::value_type(2, 2));
- assert(r == m.begin());
- assert(m.size() == 1);
- assert(r->first == 2);
- assert(r->second == 2);
+ typedef std::multimap<int, MoveOnly> M;
+ typedef typename M::iterator R;
+ typedef typename M::value_type VT;
+ M m;
+ R r = m.insert(VT(2, 2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2);
- r = m.insert(M::value_type(1, 1));
- assert(r == m.begin());
- assert(m.size() == 2);
- assert(r->first == 1);
- assert(r->second == 1);
+ r = m.insert(VT(1, 1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1);
- r = m.insert(M::value_type(3, 3));
- assert(r == prev(m.end()));
- assert(m.size() == 3);
- assert(r->first == 3);
- assert(r->second == 3);
+ r = m.insert(VT(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3);
- r = m.insert(M::value_type(3, 3));
- assert(r == prev(m.end()));
- assert(m.size() == 4);
- assert(r->first == 3);
- assert(r->second == 3);
- }
-#if TEST_STD_VER >= 11
+ r = m.insert(VT(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(r->first == 3);
+ assert(r->second == 3);
+}
+
+int main()
+{
+ do_insert_rv_test<std::multimap<int, MoveOnly>>();
{
typedef std::multimap<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M;
- typedef M::iterator R;
- M m;
- R r = m.insert(M::value_type(2, 2));
- assert(r == m.begin());
- assert(m.size() == 1);
- assert(r->first == 2);
- assert(r->second == 2);
-
- r = m.insert(M::value_type(1, 1));
- assert(r == m.begin());
- assert(m.size() == 2);
- assert(r->first == 1);
- assert(r->second == 1);
-
- r = m.insert(M::value_type(3, 3));
- assert(r == prev(m.end()));
- assert(m.size() == 3);
- assert(r->first == 3);
- assert(r->second == 3);
-
- r = m.insert(M::value_type(3, 3));
- assert(r == prev(m.end()));
- assert(m.size() == 4);
- assert(r->first == 3);
- assert(r->second == 3);
+ do_insert_rv_test<M>();
}
-#endif
-#if TEST_STD_VER > 14
{
typedef std::multimap<int, MoveOnly> M;
typedef M::iterator R;
@@ -111,6 +90,4 @@ int main()
assert(r->first == 3);
assert(r->second == 3);
}
-#endif
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
diff --git a/libcxx/test/std/containers/map_allocator_requirement_test_templates.h b/libcxx/test/std/containers/map_allocator_requirement_test_templates.h
index 91b209d0b79..2ae3a2e3c87 100644
--- a/libcxx/test/std/containers/map_allocator_requirement_test_templates.h
+++ b/libcxx/test/std/containers/map_allocator_requirement_test_templates.h
@@ -33,6 +33,8 @@ template <class Container>
void testMapInsert()
{
typedef typename Container::value_type ValueTp;
+ typedef typename Container::key_type Key;
+ typedef typename Container::mapped_type Mapped;
typedef Container C;
typedef std::pair<typename C::iterator, bool> R;
ConstructController* cc = getConstructController();
@@ -90,6 +92,18 @@ void testMapInsert()
}
}
{
+ CHECKPOINT("Testing C::insert({key, value})");
+ Container c;
+ cc->expect<ValueTp&&>();
+ assert(c.insert({42, 1}).second);
+ assert(!cc->unchecked());
+ {
+ DisableAllocationGuard g;
+ const ValueTp v2(42, 1);
+ assert(c.insert(std::move(v2)).second == false);
+ }
+ }
+ {
CHECKPOINT("Testing C::insert(std::initializer_list<ValueTp>)");
Container c;
std::initializer_list<ValueTp> il = { ValueTp(1, 1), ValueTp(2, 1) };
@@ -142,6 +156,140 @@ void testMapInsert()
}
}
+
+template <class Container>
+void testMapInsertHint()
+{
+ typedef typename Container::value_type ValueTp;
+ typedef typename Container::key_type Key;
+ typedef typename Container::mapped_type Mapped;
+ typedef typename std::pair<Key, Mapped> NonConstKeyPair;
+ typedef Container C;
+ typedef typename C::iterator It;
+ ConstructController* cc = getConstructController();
+ cc->reset();
+ {
+ CHECKPOINT("Testing C::insert(p, const value_type&)");
+ Container c;
+ const ValueTp v(42, 1);
+ cc->expect<const ValueTp&>();
+ It ret = c.insert(c.end(), v);
+ assert(ret != c.end());
+ assert(c.size() == 1);
+ assert(!cc->unchecked());
+ {
+ DisableAllocationGuard g;
+ const ValueTp v2(42, 1);
+ It ret2 = c.insert(c.begin(), v2);
+ assert(&(*ret2) == &(*ret));
+ assert(c.size() == 1);
+ }
+ }
+ {
+ CHECKPOINT("Testing C::insert(p, value_type&)");
+ Container c;
+ ValueTp v(42, 1);
+ cc->expect<ValueTp const&>();
+ It ret = c.insert(c.end(), v);
+ assert(ret != c.end());
+ assert(c.size() == 1);
+ assert(!cc->unchecked());
+ {
+ DisableAllocationGuard g;
+ ValueTp v2(42, 1);
+ It ret2 = c.insert(c.begin(), v2);
+ assert(&(*ret2) == &(*ret));
+ assert(c.size() == 1);
+ }
+ }
+ {
+ CHECKPOINT("Testing C::insert(p, value_type&&)");
+ Container c;
+ ValueTp v(42, 1);
+ cc->expect<ValueTp&&>();
+ It ret = c.insert(c.end(), std::move(v));
+ assert(ret != c.end());
+ assert(c.size() == 1);
+ assert(!cc->unchecked());
+ {
+ DisableAllocationGuard g;
+ ValueTp v2(42, 1);
+ It ret2 = c.insert(c.begin(), std::move(v2));
+ assert(&(*ret2) == &(*ret));
+ assert(c.size() == 1);
+ }
+ }
+ {
+ CHECKPOINT("Testing C::insert(p, {key, value})");
+ Container c;
+ cc->expect<ValueTp&&>();
+ It ret = c.insert(c.end(), {42, 1});
+ assert(ret != c.end());
+ assert(c.size() == 1);
+ assert(!cc->unchecked());
+ {
+ DisableAllocationGuard g;
+ It ret2 = c.insert(c.begin(), {42, 1});
+ assert(&(*ret2) == &(*ret));
+ assert(c.size() == 1);
+ }
+ }
+ {
+ CHECKPOINT("Testing C::insert(p, const value_type&&)");
+ Container c;
+ const ValueTp v(42, 1);
+ cc->expect<const ValueTp&>();
+ It ret = c.insert(c.end(), std::move(v));
+ assert(ret != c.end());
+ assert(c.size() == 1);
+ assert(!cc->unchecked());
+ {
+ DisableAllocationGuard g;
+ const ValueTp v2(42, 1);
+ It ret2 = c.insert(c.begin(), std::move(v2));
+ assert(&(*ret2) == &(*ret));
+ assert(c.size() == 1);
+ }
+ }
+ {
+ CHECKPOINT("Testing C::insert(p, pair<Key, Mapped> const&)");
+ Container c;
+ const NonConstKeyPair v(42, 1);
+ cc->expect<const NonConstKeyPair&>();
+ It ret = c.insert(c.end(), v);
+ assert(ret != c.end());
+ assert(c.size() == 1);
+ assert(!cc->unchecked());
+ {
+ DisableAllocationGuard g;
+ const NonConstKeyPair v2(42, 1);
+ It ret2 = c.insert(c.begin(), v2);
+ assert(&(*ret2) == &(*ret));
+ assert(c.size() == 1);
+ }
+ }
+ {
+ CHECKPOINT("Testing C::insert(p, pair<Key, Mapped>&&)");
+ Container c;
+ NonConstKeyPair v(42, 1);
+ cc->expect<NonConstKeyPair&&>();
+ It ret = c.insert(c.end(), std::move(v));
+ assert(ret != c.end());
+ assert(c.size() == 1);
+ assert(!cc->unchecked());
+ {
+ DisableAllocationGuard g;
+ NonConstKeyPair v2(42, 1);
+ It ret2 = c.insert(c.begin(), std::move(v2));
+ assert(&(*ret2) == &(*ret));
+ assert(c.size() == 1);
+ }
+ }
+
+
+}
+
+
template <class Container>
void testMapEmplace()
{
@@ -510,6 +658,13 @@ void testMultimapInsert()
assert(!cc->unchecked());
}
{
+ CHECKPOINT("Testing C::insert({key, value})");
+ Container c;
+ cc->expect<ValueTp&&>();
+ c.insert({42, 1});
+ assert(!cc->unchecked());
+ }
+ {
CHECKPOINT("Testing C::insert(std::initializer_list<ValueTp>)");
Container c;
std::initializer_list<ValueTp> il = { ValueTp(1, 1), ValueTp(2, 1) };
@@ -542,7 +697,47 @@ void testMultimapInsert()
c.insert(std::begin(ValueList), std::end(ValueList));
assert(!cc->unchecked());
}
+}
+
+template <class Container>
+void testMultimapInsertHint()
+{
+ typedef typename Container::value_type ValueTp;
+ typedef Container C;
+ ConstructController* cc = getConstructController();
+ cc->reset();
+ {
+ CHECKPOINT("Testing C::insert(p, const value_type&)");
+ Container c;
+ const ValueTp v(42, 1);
+ cc->expect<const ValueTp&>();
+ c.insert(c.begin(), v);
+ assert(!cc->unchecked());
+ }
+ {
+ CHECKPOINT("Testing C::insert(p, value_type&)");
+ Container c;
+ ValueTp v(42, 1);
+ cc->expect<ValueTp&>();
+ c.insert(c.begin(), v);
+ assert(!cc->unchecked());
+ }
+ {
+ CHECKPOINT("Testing C::insert(p, value_type&&)");
+ Container c;
+ ValueTp v(42, 1);
+ cc->expect<ValueTp&&>();
+ c.insert(c.begin(), std::move(v));
+ assert(!cc->unchecked());
+ }
+ {
+ CHECKPOINT("Testing C::insert(p, {key, value})");
+ Container c;
+ cc->expect<ValueTp&&>();
+ c.insert(c.begin(), {42, 1});
+ assert(!cc->unchecked());
+ }
}
#endif
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp
index 3b44e945816..00c47182c92 100644
--- a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp
@@ -25,6 +25,7 @@
int main()
{
testMapInsert<TCT::unordered_map<> >();
+ testMapInsertHint<TCT::unordered_map<> >();
testMapEmplace<TCT::unordered_map<> >();
testMapEmplaceHint<TCT::unordered_map<> >();
}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp
index a16f097b4c0..fe2b24707fb 100644
--- a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp
@@ -18,69 +18,64 @@
#include <unordered_map>
#include <cassert>
+#include "test_macros.h"
#include "min_allocator.h"
-int main()
+
+template <class Container>
+void do_insert_cv_test()
{
- {
- typedef std::unordered_map<double, int> C;
- typedef std::pair<C::iterator, bool> R;
- typedef C::value_type P;
- C c;
- R r = c.insert(P(3.5, 3));
- assert(r.second);
- assert(c.size() == 1);
- assert(r.first->first == 3.5);
- assert(r.first->second == 3);
+ typedef Container M;
+ typedef std::pair<typename M::iterator, bool> R;
+ typedef typename M::value_type VT;
+ M m;
- r = c.insert(P(3.5, 4));
- assert(!r.second);
- assert(c.size() == 1);
- assert(r.first->first == 3.5);
- assert(r.first->second == 3);
+ const VT v1(2.5, 2);
+ R r = m.insert(v1);
+ assert(r.second);
+ assert(m.size() == 1);
+ assert(r.first->first == 2.5);
+ assert(r.first->second == 2);
- r = c.insert(P(4.5, 4));
- assert(r.second);
- assert(c.size() == 2);
- assert(r.first->first == 4.5);
- assert(r.first->second == 4);
+ r = m.insert(VT(2.5, 3)); // test rvalue insertion works in C++03
+ assert(!r.second);
+ assert(m.size() == 1);
+ assert(r.first->first == 2.5);
+ assert(r.first->second == 2);
- r = c.insert(P(5.5, 4));
- assert(r.second);
- assert(c.size() == 3);
- assert(r.first->first == 5.5);
- assert(r.first->second == 4);
- }
-#if __cplusplus >= 201103L
- {
- typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>,
- min_allocator<std::pair<const double, int>>> C;
- typedef std::pair<C::iterator, bool> R;
- typedef C::value_type P;
- C c;
- R r = c.insert(P(3.5, 3));
- assert(r.second);
- assert(c.size() == 1);
- assert(r.first->first == 3.5);
- assert(r.first->second == 3);
+ const VT v2(1.5, 1);
+ r = m.insert(v2);
+ assert(r.second);
+ assert(m.size() == 2);
+ assert(r.first->first == 1.5);
+ assert(r.first->second == 1);
- r = c.insert(P(3.5, 4));
- assert(!r.second);
- assert(c.size() == 1);
- assert(r.first->first == 3.5);
- assert(r.first->second == 3);
+ const VT v3(3.5, 3);
+ r = m.insert(v3);
+ assert(r.second);
+ assert(m.size() == 3);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
- r = c.insert(P(4.5, 4));
- assert(r.second);
- assert(c.size() == 2);
- assert(r.first->first == 4.5);
- assert(r.first->second == 4);
+ const VT v4(3.5, 4);
+ r = m.insert(v4);
+ assert(!r.second);
+ assert(m.size() == 3);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+}
- r = c.insert(P(5.5, 4));
- assert(r.second);
- assert(c.size() == 3);
- assert(r.first->first == 5.5);
- assert(r.first->second == 4);
+int main()
+{
+ {
+ typedef std::unordered_map<double, int> M;
+ do_insert_cv_test<M>();
+ }
+#if TEST_STD_VER >= 11
+ {
+ typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>,
+ min_allocator<std::pair<const double, int>>> M;
+ do_insert_cv_test<M>();
}
#endif
}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp
index 1618c1019e1..04d01eb466e 100644
--- a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
@@ -55,7 +57,6 @@ int main()
assert(r->first == 5.5);
assert(r->second == 4);
}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef std::unordered_map<MoveOnly, MoveOnly> C;
typedef C::iterator R;
@@ -82,8 +83,6 @@ int main()
assert(r->first == 5);
assert(r->second == 4);
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#if __cplusplus >= 201103L
{
typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>,
min_allocator<std::pair<const double, int>>> C;
@@ -111,7 +110,6 @@ int main()
assert(r->first == 5.5);
assert(r->second == 4);
}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>,
min_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
@@ -139,7 +137,31 @@ int main()
assert(r->first == 5);
assert(r->second == 4);
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<double, MoveOnly> C;
+ typedef C::iterator R;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, {3.5, 3});
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), {3.5, 4});
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), {4.5, 4});
+ assert(c.size() == 2);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), {5.5, 4});
+ assert(c.size() == 3);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
#if _LIBCPP_DEBUG >= 1
{
typedef std::unordered_map<double, int> C;
@@ -152,5 +174,4 @@ int main()
assert(false);
}
#endif
-#endif
}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp
index f53dc6c7e97..faf5b046b5d 100644
--- a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
@@ -54,7 +56,6 @@ int main()
assert(r.first->first == 5.5);
assert(r.first->second == 4);
}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef std::unordered_map<MoveOnly, MoveOnly> C;
typedef std::pair<C::iterator, bool> R;
@@ -84,8 +85,6 @@ int main()
assert(r.first->first == 5);
assert(r.first->second == 4);
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#if __cplusplus >= 201103L
{
typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>,
min_allocator<std::pair<const double, int>>> C;
@@ -116,7 +115,6 @@ int main()
assert(r.first->first == 5.5);
assert(r.first->second == 4);
}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>,
min_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
@@ -147,6 +145,32 @@ int main()
assert(r.first->first == 5);
assert(r.first->second == 4);
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#endif
+ {
+ typedef std::unordered_map<double, MoveOnly> C;
+ typedef std::pair<C::iterator, bool> R;
+ C c;
+ R r = c.insert({3.5, 3});
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert({3.5, 4});
+ assert(!r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert({4.5, 4});
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4.5);
+ assert(r.first->second == 4);
+
+ r = c.insert({5.5, 4});
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5.5);
+ assert(r.first->second == 4);
+ }
}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_allocator_requirements.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_allocator_requirements.pass.cpp
index 1145eb99091..30f78936ff9 100644
--- a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_allocator_requirements.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_allocator_requirements.pass.cpp
@@ -23,4 +23,5 @@
int main()
{
testMultimapInsert<TCT::unordered_multimap<> >();
+ testMultimapInsertHint<TCT::unordered_multimap<> >();
}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp
index 7116fa02b6f..d6c0dbdbed0 100644
--- a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
@@ -55,7 +57,6 @@ int main()
assert(r->first == 5.5);
assert(r->second == 4);
}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
typedef C::iterator R;
@@ -82,8 +83,6 @@ int main()
assert(r->first == 5);
assert(r->second == 4);
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#if __cplusplus >= 201103L
{
typedef std::unordered_multimap<double, int, std::hash<double>, std::equal_to<double>,
min_allocator<std::pair<const double, int>>> C;
@@ -111,7 +110,6 @@ int main()
assert(r->first == 5.5);
assert(r->second == 4);
}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>,
min_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
@@ -139,7 +137,31 @@ int main()
assert(r->first == 5);
assert(r->second == 4);
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multimap<double, int> C;
+ typedef C::iterator R;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, {3.5, 3});
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(r, {3.5, 4});
+ assert(c.size() == 2);
+ assert(r->first == 3.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), {4.5, 4});
+ assert(c.size() == 3);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), {5.5, 4});
+ assert(c.size() == 4);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
#if _LIBCPP_DEBUG >= 1
{
typedef std::unordered_multimap<double, int> C;
@@ -152,5 +174,4 @@ int main()
assert(false);
}
#endif
-#endif
}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp
index 5a98467e9d0..6735b8af5a0 100644
--- a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <unordered_map>
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
@@ -50,7 +52,6 @@ int main()
assert(r->first == 5.5);
assert(r->second == 4);
}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
typedef C::iterator R;
@@ -76,8 +77,6 @@ int main()
assert(r->first == 5);
assert(r->second == 4);
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#if __cplusplus >= 201103L
{
typedef std::unordered_multimap<double, int, std::hash<double>, std::equal_to<double>,
min_allocator<std::pair<const double, int>>> C;
@@ -104,7 +103,6 @@ int main()
assert(r->first == 5.5);
assert(r->second == 4);
}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>,
min_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
@@ -131,6 +129,28 @@ int main()
assert(r->first == 5);
assert(r->second == 4);
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#endif
+ {
+ typedef std::unordered_multimap<double, MoveOnly> C;
+ typedef C::iterator R;
+ C c;
+ R r = c.insert({3.5, 3});
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert({3.5, 4});
+ assert(c.size() == 2);
+ assert(r->first == 3.5);
+ assert(r->second == 4);
+
+ r = c.insert({4.5, 4});
+ assert(c.size() == 3);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert({5.5, 4});
+ assert(c.size() == 4);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
}
OpenPOWER on IntegriCloud