summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libcxx/include/map84
-rw-r--r--libcxx/include/unordered_map87
-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
12 files changed, 179 insertions, 174 deletions
diff --git a/libcxx/include/map b/libcxx/include/map
index d0cd0c6b844..4107eadd754 100644
--- a/libcxx/include/map
+++ b/libcxx/include/map
@@ -1003,26 +1003,14 @@ private:
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
__node_holder __construct_node();
template <class _A0>
- typename enable_if
- <
- is_constructible<value_type, _A0>::value,
- __node_holder
- >::type
- __construct_node(_A0&& __a0);
- template <class _A0>
- typename enable_if
- <
- is_constructible<key_type, _A0>::value,
- __node_holder
- >::type
- __construct_node(_A0&& __a0);
+ __node_holder __construct_node(_A0&& __a0);
+ __node_holder __construct_node_with_key(key_type&& __k);
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class _A0, class _A1, class ..._Args>
__node_holder __construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args);
#endif // _LIBCPP_HAS_NO_VARIADICS
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- __node_holder __construct_node(const key_type& __k);
#endif
+ __node_holder __construct_node_with_key(const key_type& __k);
__node_base_pointer&
__find_equal_key(__node_base_pointer& __parent, const key_type& __k);
@@ -1150,11 +1138,7 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node()
template <class _Key, class _Tp, class _Compare, class _Allocator>
template <class _A0>
-typename enable_if
-<
- is_constructible<pair<const _Key, _Tp>, _A0>::value,
- typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
->::type
+typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
map<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0)
{
__node_allocator& __na = __tree_.__node_alloc();
@@ -1166,21 +1150,16 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0)
}
template <class _Key, class _Tp, class _Compare, class _Allocator>
-template <class _A0>
-typename enable_if
-<
- is_constructible<_Key, _A0>::value,
- typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
->::type
-map<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0)
+typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
+map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(key_type&& __k)
{
__node_allocator& __na = __tree_.__node_alloc();
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
- __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), _VSTD::forward<_A0>(__a0));
+ __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), _VSTD::move(__k));
__h.get_deleter().__first_constructed = true;
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
__h.get_deleter().__second_constructed = true;
- return __h;
+ return _VSTD::move(__h);
}
#ifndef _LIBCPP_HAS_NO_VARIADICS
@@ -1202,11 +1181,11 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0, _A1&& __a1, _
#endif // _LIBCPP_HAS_NO_VARIADICS
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _Key, class _Tp, class _Compare, class _Allocator>
typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
-map<_Key, _Tp, _Compare, _Allocator>::__construct_node(const key_type& __k)
+map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type& __k)
{
__node_allocator& __na = __tree_.__node_alloc();
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
@@ -1217,8 +1196,6 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node(const key_type& __k)
return _VSTD::move(__h);
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
template <class _Key, class _Tp, class _Compare, class _Allocator>
_Tp&
map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k)
@@ -1228,7 +1205,7 @@ map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k)
__node_pointer __r = static_cast<__node_pointer>(__child);
if (__child == nullptr)
{
- __node_holder __h = __construct_node(__k);
+ __node_holder __h = __construct_node_with_key(__k);
__tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
__r = __h.release();
}
@@ -1246,7 +1223,7 @@ map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k)
__node_pointer __r = static_cast<__node_pointer>(__child);
if (__child == nullptr)
{
- __node_holder __h = __construct_node(_VSTD::move(__k));
+ __node_holder __h = __construct_node_with_key(_VSTD::move(__k));
__tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
__r = __h.release();
}
@@ -1733,18 +1710,7 @@ private:
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
__node_holder __construct_node();
template <class _A0>
- typename enable_if
- <
- is_constructible<value_type, _A0>::value,
- __node_holder
- >::type
- __construct_node(_A0&& __a0);
- template <class _A0>
- typename enable_if
- <
- is_constructible<key_type, _A0>::value,
- __node_holder
- >::type
+ __node_holder
__construct_node(_A0&& __a0);
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class _A0, class _A1, class ..._Args>
@@ -1783,11 +1749,7 @@ multimap<_Key, _Tp, _Compare, _Allocator>::__construct_node()
template <class _Key, class _Tp, class _Compare, class _Allocator>
template <class _A0>
-typename enable_if
-<
- is_constructible<pair<const _Key, _Tp>, _A0>::value,
- typename multimap<_Key, _Tp, _Compare, _Allocator>::__node_holder
->::type
+typename multimap<_Key, _Tp, _Compare, _Allocator>::__node_holder
multimap<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0)
{
__node_allocator& __na = __tree_.__node_alloc();
@@ -1798,24 +1760,6 @@ multimap<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0)
return __h;
}
-template <class _Key, class _Tp, class _Compare, class _Allocator>
-template <class _A0>
-typename enable_if
-<
- is_constructible<_Key, _A0>::value,
- typename multimap<_Key, _Tp, _Compare, _Allocator>::__node_holder
->::type
-multimap<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0)
-{
- __node_allocator& __na = __tree_.__node_alloc();
- __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
- __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), _VSTD::forward<_A0>(__a0));
- __h.get_deleter().__first_constructed = true;
- __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
- __h.get_deleter().__second_constructed = true;
- return __h;
-}
-
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class _Key, class _Tp, class _Compare, class _Allocator>
diff --git a/libcxx/include/unordered_map b/libcxx/include/unordered_map
index cc30d763424..0d2ce292076 100644
--- a/libcxx/include/unordered_map
+++ b/libcxx/include/unordered_map
@@ -917,26 +917,15 @@ private:
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
__node_holder __construct_node();
template <class _A0>
- typename enable_if
- <
- is_constructible<value_type, _A0>::value,
- __node_holder
- >::type
- __construct_node(_A0&& __a0);
- template <class _A0>
- typename enable_if
- <
- is_constructible<key_type, _A0>::value,
- __node_holder
- >::type
+ __node_holder
__construct_node(_A0&& __a0);
+ __node_holder __construct_node_with_key(key_type&& __k);
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class _A0, class _A1, class ..._Args>
__node_holder __construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args);
#endif // _LIBCPP_HAS_NO_VARIADICS
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- __node_holder __construct_node(const key_type& __k);
-#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ __node_holder __construct_node_with_key(const key_type& __k);
};
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@@ -1115,11 +1104,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node()
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
template <class _A0>
-typename enable_if
-<
- is_constructible<pair<const _Key, _Tp>, _A0>::value,
- typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
->::type
+typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0)
{
__node_allocator& __na = __table_.__node_alloc();
@@ -1132,22 +1117,16 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0)
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-template <class _A0>
-typename enable_if
-<
- is_constructible<_Key, _A0>::value,
- typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
->::type
-unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0)
+typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(key_type&& __k)
{
__node_allocator& __na = __table_.__node_alloc();
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
- __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first),
- _VSTD::forward<_A0>(__a0));
+ __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), _VSTD::move(__k));
__h.get_deleter().__first_constructed = true;
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
__h.get_deleter().__second_constructed = true;
- return __h;
+ return _VSTD::move(__h);
}
#ifndef _LIBCPP_HAS_NO_VARIADICS
@@ -1182,11 +1161,11 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace(_Args&&... __args)
}
#endif // _LIBCPP_HAS_NO_VARIADICS
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
-unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(const key_type& __k)
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const key_type& __k)
{
__node_allocator& __na = __table_.__node_alloc();
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
@@ -1197,8 +1176,6 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(const key_type&
return _VSTD::move(__h);
}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
inline _LIBCPP_INLINE_VISIBILITY
@@ -1217,7 +1194,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
iterator __i = find(__k);
if (__i != end())
return __i->second;
- __node_holder __h = __construct_node(__k);
+ __node_holder __h = __construct_node_with_key(__k);
pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
__h.release();
return __r.first->second;
@@ -1232,7 +1209,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k)
iterator __i = find(__k);
if (__i != end())
return __i->second;
- __node_holder __h = __construct_node(_VSTD::move(__k));
+ __node_holder __h = __construct_node_with_key(_VSTD::move(__k));
pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
__h.release();
return __r.first->second;
@@ -1595,18 +1572,7 @@ private:
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
__node_holder __construct_node();
template <class _A0>
- typename enable_if
- <
- is_constructible<value_type, _A0>::value,
- __node_holder
- >::type
- __construct_node(_A0&& __a0);
- template <class _A0>
- typename enable_if
- <
- is_constructible<key_type, _A0>::value,
- __node_holder
- >::type
+ __node_holder
__construct_node(_A0&& __a0);
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class _A0, class _A1, class ..._Args>
@@ -1793,11 +1759,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node()
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
template <class _A0>
-typename enable_if
-<
- is_constructible<pair<const _Key, _Tp>, _A0>::value,
- typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
->::type
+typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0)
{
__node_allocator& __na = __table_.__node_alloc();
@@ -1809,25 +1771,6 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0
return __h;
}
-template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
-template <class _A0>
-typename enable_if
-<
- is_constructible<_Key, _A0>::value,
- typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
->::type
-unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0)
-{
- __node_allocator& __na = __table_.__node_alloc();
- __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
- __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first),
- _VSTD::forward<_A0>(__a0));
- __h.get_deleter().__first_constructed = true;
- __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
- __h.get_deleter().__second_constructed = true;
- return __h;
-}
-
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
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