summaryrefslogtreecommitdiffstats
path: root/libcxx/test
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2013-07-04 20:59:16 +0000
committerHoward Hinnant <hhinnant@apple.com>2013-07-04 20:59:16 +0000
commit4a95f9eb7e9b2ffaea49d424e74099d54099ce36 (patch)
treeb175c642b8d7ecaa210d5dc591e552821dff3969 /libcxx/test
parentbbdf669bde57f1a2f8fa1a3d4fbb46b1e3c25a4c (diff)
downloadbcm5719-llvm-4a95f9eb7e9b2ffaea49d424e74099d54099ce36.tar.gz
bcm5719-llvm-4a95f9eb7e9b2ffaea49d424e74099d54099ce36.zip
Removed extension in [unordered_][multi]map which allowed one to emplace using just an argument for the key, as opposed to using piecewise_construct. However a bug report exposed that this created an unfortunate ambiguity. People who are currently using the extension will be notified the next time they compile, and will have to change to using piecewise_construct. There are no ABI issues with the removal of this extension. This fixes http://llvm.org/bugs/show_bug.cgi?id=16542
llvm-svn: 185666
Diffstat (limited to 'libcxx/test')
-rw-r--r--libcxx/test/containers/associative/map/map.access/index_tuple.pass.cpp33
-rw-r--r--libcxx/test/containers/associative/map/map.modifiers/emplace.pass.cpp18
-rw-r--r--libcxx/test/containers/associative/map/map.modifiers/emplace_hint.pass.cpp24
-rw-r--r--libcxx/test/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp18
-rw-r--r--libcxx/test/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp24
-rw-r--r--libcxx/test/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp41
-rw-r--r--libcxx/test/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp6
-rw-r--r--libcxx/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp6
-rw-r--r--libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp6
-rw-r--r--libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp6
10 files changed, 150 insertions, 32 deletions
diff --git a/libcxx/test/containers/associative/map/map.access/index_tuple.pass.cpp b/libcxx/test/containers/associative/map/map.access/index_tuple.pass.cpp
new file mode 100644
index 00000000000..9a00829eadd
--- /dev/null
+++ b/libcxx/test/containers/associative/map/map.access/index_tuple.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// mapped_type& operator[](const key_type& k);
+
+// http://llvm.org/bugs/show_bug.cgi?id=16542
+
+#include <map>
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+#include <tuple>
+
+#endif
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ using namespace std;
+ map<tuple<int,int>, size_t> m;
+ m[make_tuple(2,3)]=7;
+#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 3ade69db72e..9a87becf684 100644
--- a/libcxx/test/containers/associative/map/map.modifiers/emplace.pass.cpp
+++ b/libcxx/test/containers/associative/map/map.modifiers/emplace.pass.cpp
@@ -37,14 +37,16 @@ int main()
assert(m.begin()->first == 0);
assert(m.begin()->second == DefaultOnly());
assert(DefaultOnly::count == 1);
- r = m.emplace(1);
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple());
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);
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple());
assert(!r.second);
assert(r.first == next(m.begin()));
assert(m.size() == 2);
@@ -57,7 +59,8 @@ int main()
typedef std::map<int, Emplaceable> M;
typedef std::pair<M::iterator, bool> R;
M m;
- R r = m.emplace(2);
+ R r = m.emplace(std::piecewise_construct, std::forward_as_tuple(2),
+ std::forward_as_tuple());
assert(r.second);
assert(r.first == m.begin());
assert(m.size() == 1);
@@ -102,14 +105,16 @@ int main()
assert(m.begin()->first == 0);
assert(m.begin()->second == DefaultOnly());
assert(DefaultOnly::count == 1);
- r = m.emplace(1);
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple());
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);
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple());
assert(!r.second);
assert(r.first == next(m.begin()));
assert(m.size() == 2);
@@ -122,7 +127,8 @@ int main()
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);
+ R r = m.emplace(std::piecewise_construct, std::forward_as_tuple(2),
+ std::forward_as_tuple());
assert(r.second);
assert(r.first == m.begin());
assert(m.size() == 1);
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 e1eb586d487..bf8173f770d 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
@@ -35,13 +35,17 @@ int main()
assert(m.begin()->first == 0);
assert(m.begin()->second == DefaultOnly());
assert(DefaultOnly::count == 1);
- r = m.emplace_hint(m.end(), 1);
+ r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple());
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);
+ r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple());
assert(r == next(m.begin()));
assert(m.size() == 2);
assert(next(m.begin())->first == 1);
@@ -53,7 +57,9 @@ int main()
typedef std::map<int, Emplaceable> M;
typedef M::iterator R;
M m;
- R r = m.emplace_hint(m.end(), 2);
+ R r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(2),
+ std::forward_as_tuple());
assert(r == m.begin());
assert(m.size() == 1);
assert(m.begin()->first == 2);
@@ -95,13 +101,17 @@ int main()
assert(m.begin()->first == 0);
assert(m.begin()->second == DefaultOnly());
assert(DefaultOnly::count == 1);
- r = m.emplace_hint(m.end(), 1);
+ r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple());
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);
+ r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple());
assert(r == next(m.begin()));
assert(m.size() == 2);
assert(next(m.begin())->first == 1);
@@ -113,7 +123,9 @@ int main()
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);
+ R r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(2),
+ std::forward_as_tuple());
assert(r == m.begin());
assert(m.size() == 1);
assert(m.begin()->first == 2);
diff --git a/libcxx/test/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp
index c91909e7224..7af44261b43 100644
--- a/libcxx/test/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp
+++ b/libcxx/test/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp
@@ -35,13 +35,15 @@ int main()
assert(m.begin()->first == 0);
assert(m.begin()->second == DefaultOnly());
assert(DefaultOnly::count == 1);
- r = m.emplace(1);
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple());
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(1);
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple());
assert(r == next(m.begin(), 2));
assert(m.size() == 3);
assert(next(m.begin(), 2)->first == 1);
@@ -53,7 +55,8 @@ int main()
typedef std::multimap<int, Emplaceable> M;
typedef M::iterator R;
M m;
- R r = m.emplace(2);
+ R r = m.emplace(std::piecewise_construct, std::forward_as_tuple(2),
+ std::forward_as_tuple());
assert(r == m.begin());
assert(m.size() == 1);
assert(m.begin()->first == 2);
@@ -93,13 +96,15 @@ int main()
assert(m.begin()->first == 0);
assert(m.begin()->second == DefaultOnly());
assert(DefaultOnly::count == 1);
- r = m.emplace(1);
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple());
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(1);
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple());
assert(r == next(m.begin(), 2));
assert(m.size() == 3);
assert(next(m.begin(), 2)->first == 1);
@@ -111,7 +116,8 @@ int main()
typedef std::multimap<int, Emplaceable, std::less<int>, min_allocator<std::pair<const int, Emplaceable>>> M;
typedef M::iterator R;
M m;
- R r = m.emplace(2);
+ R r = m.emplace(std::piecewise_construct, std::forward_as_tuple(2),
+ std::forward_as_tuple());
assert(r == m.begin());
assert(m.size() == 1);
assert(m.begin()->first == 2);
diff --git a/libcxx/test/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp b/libcxx/test/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp
index 8dc3195b711..3f94c03a3e5 100644
--- a/libcxx/test/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp
+++ b/libcxx/test/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp
@@ -35,13 +35,17 @@ int main()
assert(m.begin()->first == 0);
assert(m.begin()->second == DefaultOnly());
assert(DefaultOnly::count == 1);
- r = m.emplace_hint(m.cend(), 1);
+ r = m.emplace_hint(m.cend(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple());
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.cend(), 1);
+ r = m.emplace_hint(m.cend(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple());
assert(r == next(m.begin(), 2));
assert(m.size() == 3);
assert(next(m.begin(), 2)->first == 1);
@@ -53,7 +57,9 @@ int main()
typedef std::multimap<int, Emplaceable> M;
typedef M::iterator R;
M m;
- R r = m.emplace_hint(m.cend(), 2);
+ R r = m.emplace_hint(m.cend(), std::piecewise_construct,
+ std::forward_as_tuple(2),
+ std::forward_as_tuple());
assert(r == m.begin());
assert(m.size() == 1);
assert(m.begin()->first == 2);
@@ -95,13 +101,17 @@ int main()
assert(m.begin()->first == 0);
assert(m.begin()->second == DefaultOnly());
assert(DefaultOnly::count == 1);
- r = m.emplace_hint(m.cend(), 1);
+ r = m.emplace_hint(m.cend(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple());
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.cend(), 1);
+ r = m.emplace_hint(m.cend(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple());
assert(r == next(m.begin(), 2));
assert(m.size() == 3);
assert(next(m.begin(), 2)->first == 1);
@@ -113,7 +123,9 @@ int main()
typedef std::multimap<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.cend(), 2);
+ R r = m.emplace_hint(m.cend(), std::piecewise_construct,
+ std::forward_as_tuple(2),
+ std::forward_as_tuple());
assert(r == m.begin());
assert(m.size() == 1);
assert(m.begin()->first == 2);
diff --git a/libcxx/test/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp b/libcxx/test/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp
new file mode 100644
index 00000000000..c319b5c30b2
--- /dev/null
+++ b/libcxx/test/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// mapped_type& operator[](const key_type& k);
+
+// http://llvm.org/bugs/show_bug.cgi?id=16542
+
+#include <unordered_map>
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+#include <tuple>
+
+using namespace std;
+
+struct my_hash
+{
+ size_t operator()(const tuple<int,int>&) const {return 0;}
+};
+
+#endif
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ unordered_map<tuple<int,int>, size_t, my_hash> m;
+ m[make_tuple(2,3)]=7;
+#endif
+}
diff --git a/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp b/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp
index 515b32925ca..a115101d761 100644
--- a/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp
+++ b/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp
@@ -29,7 +29,8 @@ int main()
typedef std::unordered_map<int, Emplaceable> C;
typedef std::pair<C::iterator, bool> R;
C c;
- R r = c.emplace(3);
+ R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
assert(r.second);
assert(c.size() == 1);
assert(r.first->first == 3);
@@ -54,7 +55,8 @@ int main()
min_allocator<std::pair<const int, Emplaceable>>> C;
typedef std::pair<C::iterator, bool> R;
C c;
- R r = c.emplace(3);
+ R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
assert(r.second);
assert(c.size() == 1);
assert(r.first->first == 3);
diff --git a/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp b/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp
index 6c2a75a2913..6d6f3315e1a 100644
--- a/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp
+++ b/libcxx/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp
@@ -30,7 +30,8 @@ int main()
typedef C::iterator R;
C c;
C::const_iterator e = c.end();
- R r = c.emplace_hint(e, 3);
+ R r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
assert(c.size() == 1);
assert(r->first == 3);
assert(r->second == Emplaceable());
@@ -53,7 +54,8 @@ int main()
typedef C::iterator R;
C c;
C::const_iterator e = c.end();
- R r = c.emplace_hint(e, 3);
+ R r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
assert(c.size() == 1);
assert(r->first == 3);
assert(r->second == Emplaceable());
diff --git a/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp b/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp
index 244419dc221..80453b199d7 100644
--- a/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp
+++ b/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp
@@ -29,7 +29,8 @@ int main()
typedef std::unordered_multimap<int, Emplaceable> C;
typedef C::iterator R;
C c;
- R r = c.emplace(3);
+ R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
assert(c.size() == 1);
assert(r->first == 3);
assert(r->second == Emplaceable());
@@ -51,7 +52,8 @@ int main()
min_allocator<std::pair<const int, Emplaceable>>> C;
typedef C::iterator R;
C c;
- R r = c.emplace(3);
+ R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
assert(c.size() == 1);
assert(r->first == 3);
assert(r->second == Emplaceable());
diff --git a/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp b/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp
index 576be4e37aa..bad1ee28f22 100644
--- a/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp
+++ b/libcxx/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp
@@ -30,7 +30,8 @@ int main()
typedef C::iterator R;
C c;
C::const_iterator e = c.end();
- R r = c.emplace_hint(e, 3);
+ R r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
assert(c.size() == 1);
assert(r->first == 3);
assert(r->second == Emplaceable());
@@ -61,7 +62,8 @@ int main()
typedef C::iterator R;
C c;
C::const_iterator e = c.end();
- R r = c.emplace_hint(e, 3);
+ R r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
assert(c.size() == 1);
assert(r->first == 3);
assert(r->second == Emplaceable());
OpenPOWER on IntegriCloud