aboutsummaryrefslogtreecommitdiff
path: root/test/std/containers/associative/map/map.modifiers
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/containers/associative/map/map.modifiers')
-rw-r--r--test/std/containers/associative/map/map.modifiers/clear.pass.cpp2
-rw-r--r--test/std/containers/associative/map/map.modifiers/emplace.pass.cpp2
-rw-r--r--test/std/containers/associative/map/map.modifiers/emplace_hint.pass.cpp6
-rw-r--r--test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp4
-rw-r--r--test/std/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp2
-rw-r--r--test/std/containers/associative/map/map.modifiers/erase_key.pass.cpp2
-rw-r--r--test/std/containers/associative/map/map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp31
-rw-r--r--test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp103
-rw-r--r--test/std/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp2
-rw-r--r--test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp91
-rw-r--r--test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp2
-rw-r--r--test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp96
-rw-r--r--test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp11
-rw-r--r--test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp108
-rw-r--r--test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp13
15 files changed, 210 insertions, 265 deletions
diff --git a/test/std/containers/associative/map/map.modifiers/clear.pass.cpp b/test/std/containers/associative/map/map.modifiers/clear.pass.cpp
index c37499df307a..1f36a6f10cb0 100644
--- a/test/std/containers/associative/map/map.modifiers/clear.pass.cpp
+++ b/test/std/containers/associative/map/map.modifiers/clear.pass.cpp
@@ -39,7 +39,7 @@ int main()
m.clear();
assert(m.size() == 0);
}
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
{
typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
typedef std::pair<int, double> P;
diff --git a/test/std/containers/associative/map/map.modifiers/emplace.pass.cpp b/test/std/containers/associative/map/map.modifiers/emplace.pass.cpp
index 81846c6647c6..63d014fe8cc5 100644
--- a/test/std/containers/associative/map/map.modifiers/emplace.pass.cpp
+++ b/test/std/containers/associative/map/map.modifiers/emplace.pass.cpp
@@ -92,7 +92,7 @@ int main()
assert(m.begin()->first == 2);
assert(m.begin()->second == 3.5);
}
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
{
typedef std::map<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M;
typedef std::pair<M::iterator, bool> R;
diff --git a/test/std/containers/associative/map/map.modifiers/emplace_hint.pass.cpp b/test/std/containers/associative/map/map.modifiers/emplace_hint.pass.cpp
index 15f74b17e786..319a239525ad 100644
--- a/test/std/containers/associative/map/map.modifiers/emplace_hint.pass.cpp
+++ b/test/std/containers/associative/map/map.modifiers/emplace_hint.pass.cpp
@@ -64,7 +64,7 @@ int main()
assert(m.size() == 1);
assert(m.begin()->first == 2);
assert(m.begin()->second == Emplaceable());
- r = m.emplace_hint(m.end(), std::piecewise_construct,
+ 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());
@@ -89,7 +89,7 @@ int main()
assert(m.begin()->first == 2);
assert(m.begin()->second == 3.5);
}
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
{
typedef std::map<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M;
typedef M::iterator R;
@@ -130,7 +130,7 @@ int main()
assert(m.size() == 1);
assert(m.begin()->first == 2);
assert(m.begin()->second == Emplaceable());
- r = m.emplace_hint(m.end(), std::piecewise_construct,
+ 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());
diff --git a/test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp b/test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp
index 15c5ce041b68..cd65c4302af7 100644
--- a/test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp
+++ b/test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp
@@ -134,7 +134,7 @@ int main()
assert(i == m.begin());
assert(i == m.end());
}
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
{
typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
typedef std::pair<int, double> P;
@@ -242,7 +242,7 @@ int main()
assert(i == m.end());
}
#endif
-#if __cplusplus >= 201402L
+#if TEST_STD_VER >= 14
{
// This is LWG #2059
typedef TemplateConstructor T;
diff --git a/test/std/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp b/test/std/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp
index 1b49956d8a5a..144cfac2ccb5 100644
--- a/test/std/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp
+++ b/test/std/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp
@@ -86,7 +86,7 @@ int main()
assert(i == m.begin());
assert(i == m.end());
}
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
{
typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
typedef std::pair<int, double> P;
diff --git a/test/std/containers/associative/map/map.modifiers/erase_key.pass.cpp b/test/std/containers/associative/map/map.modifiers/erase_key.pass.cpp
index e41f5129140e..c1b31e78d3ef 100644
--- a/test/std/containers/associative/map/map.modifiers/erase_key.pass.cpp
+++ b/test/std/containers/associative/map/map.modifiers/erase_key.pass.cpp
@@ -145,7 +145,7 @@ int main()
assert(m.size() == 0);
assert(s == 1);
}
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
{
typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
typedef std::pair<int, double> P;
diff --git a/test/std/containers/associative/map/map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp
new file mode 100644
index 000000000000..d98047d02e7d
--- /dev/null
+++ b/test/std/containers/associative/map/map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// insert(...);
+// emplace(...);
+// emplace_hint(...);
+
+// UNSUPPORTED: c++98, c++03
+
+#include <map>
+
+#include "container_test_types.h"
+#include "../../../map_allocator_requirement_test_templates.h"
+
+int main()
+{
+ testMapInsert<TCT::map<> >();
+ testMapInsertHint<TCT::map<> >();
+ testMapEmplace<TCT::map<> >();
+ testMapEmplaceHint<TCT::map<> >();
+}
diff --git a/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp
index 3d28242fd322..e2ffcba375fa 100644
--- a/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp
+++ b/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/test/std/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp
index ab325ed45bfc..9cf3f3dcf74f 100644
--- a/test/std/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp
+++ b/test/std/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp
@@ -43,7 +43,7 @@ int main()
assert(*next(m.begin()) == V(2, 1));
assert(*next(m.begin(), 2) == V(3, 1));
}
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
{
typedef std::pair<const int, double> V;
std::map<int, double, std::less<int>, min_allocator<V>> m =
diff --git a/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp
index 278db4631a8c..0c7e124e0d1c 100644
--- a/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp
+++ b/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/test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp
index 964738b4a68a..edc1a1e2c62b 100644
--- a/test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp
+++ b/test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp
@@ -47,7 +47,7 @@ int main()
assert(next(m.begin(), 2)->first == 3);
assert(next(m.begin(), 2)->second == 1);
}
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
{
typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
typedef std::pair<int, double> P;
diff --git a/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp
index 9db1e5c70732..3edb9c06e7c0 100644
--- a/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp
+++ b/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/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp
index 484ed06247d1..8689dc7284d5 100644
--- a/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp
+++ b/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// UNSUPPORTED: c++03, c++11, c++14
+// UNSUPPORTED: c++98, c++03, c++11, c++14
// <map>
@@ -22,7 +22,6 @@
// template <class M>
// iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17
-#include <__config>
#include <map>
#include <cassert>
#include <tuple>
@@ -60,9 +59,6 @@ public:
int main()
{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#ifndef _LIBCPP_HAS_NO_VARIADICS
-
{ // pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
typedef std::map<int, Moveable> M;
typedef std::pair<M::iterator, bool> R;
@@ -186,7 +182,4 @@ int main()
assert(r->first.get() == 3); // key
assert(r->second.get() == 5); // value
}
-
-#endif // _LIBCPP_HAS_NO_VARIADICS
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-} \ No newline at end of file
+}
diff --git a/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp
index 23eb84d687ff..503d9291076d 100644
--- a/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp
+++ b/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/test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp b/test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp
index 8e0dd7577bbd..63704c91440e 100644
--- a/test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp
+++ b/test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// UNSUPPORTED: c++03, c++11, c++14
+// UNSUPPORTED: c++98, c++03, c++11, c++14
// <map>
@@ -22,7 +22,6 @@
// template <class... Args>
// iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17
-#include <__config>
#include <map>
#include <cassert>
#include <tuple>
@@ -58,9 +57,6 @@ public:
int main()
{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#ifndef _LIBCPP_HAS_NO_VARIADICS
-
{ // pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
typedef std::map<int, Moveable> M;
typedef std::pair<M::iterator, bool> R;
@@ -104,7 +100,7 @@ int main()
assert(r.first->second.get() == -1); // value
}
- { // pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
+ { // pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
typedef std::map<Moveable, Moveable> M;
typedef std::pair<M::iterator, bool> R;
M m;
@@ -140,7 +136,7 @@ int main()
m.try_emplace ( i, Moveable(i, (double) i));
assert(m.size() == 10);
M::const_iterator it = m.find(2);
-
+
Moveable mv1(3, 3.0);
for (int i=0; i < 20; i += 2)
{
@@ -183,7 +179,4 @@ int main()
assert(r->first.get() == 3); // key
assert(r->second.get() == 4); // value
}
-
-#endif // _LIBCPP_HAS_NO_VARIADICS
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}