From 4a95f9eb7e9b2ffaea49d424e74099d54099ce36 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Thu, 4 Jul 2013 20:59:16 +0000 Subject: [PATCH] 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 --- libcxx/include/map | 84 ++++----------------- libcxx/include/unordered_map | 87 ++++------------------ .../map/map.access/index_tuple.pass.cpp | 33 ++++++++ .../associative/map/map.modifiers/emplace.pass.cpp | 18 +++-- .../map/map.modifiers/emplace_hint.pass.cpp | 24 ++++-- .../multimap/multimap.modifiers/emplace.pass.cpp | 18 +++-- .../multimap.modifiers/emplace_hint.pass.cpp | 24 ++++-- .../unord.map/unord.map.elem/index_tuple.pass.cpp | 41 ++++++++++ .../unorder.map.modifiers/emplace.pass.cpp | 6 +- .../unorder.map.modifiers/emplace_hint.pass.cpp | 6 +- .../unord.multimap.modifiers/emplace.pass.cpp | 6 +- .../unord.multimap.modifiers/emplace_hint.pass.cpp | 6 +- 12 files changed, 179 insertions(+), 174 deletions(-) create mode 100644 libcxx/test/containers/associative/map/map.access/index_tuple.pass.cpp create mode 100644 libcxx/test/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp diff --git a/libcxx/include/map b/libcxx/include/map index d0cd0c6..4107ead 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 - typename enable_if - < - is_constructible::value, - __node_holder - >::type - __construct_node(_A0&& __a0); - template - typename enable_if - < - is_constructible::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 __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 template -typename enable_if -< - is_constructible, _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 -template -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 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 _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 - typename enable_if - < - is_constructible::value, - __node_holder - >::type - __construct_node(_A0&& __a0); - template - typename enable_if - < - is_constructible::value, - __node_holder - >::type + __node_holder __construct_node(_A0&& __a0); #ifndef _LIBCPP_HAS_NO_VARIADICS template @@ -1783,11 +1749,7 @@ multimap<_Key, _Tp, _Compare, _Allocator>::__construct_node() template template -typename enable_if -< - is_constructible, _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 -template -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 diff --git a/libcxx/include/unordered_map b/libcxx/include/unordered_map index cc30d76..0d2ce29 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 - typename enable_if - < - is_constructible::value, - __node_holder - >::type - __construct_node(_A0&& __a0); - template - typename enable_if - < - is_constructible::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 __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 @@ -1115,11 +1104,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node() template template -typename enable_if -< - is_constructible, _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 -template -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 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 template 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 __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 __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 - typename enable_if - < - is_constructible::value, - __node_holder - >::type - __construct_node(_A0&& __a0); - template - typename enable_if - < - is_constructible::value, - __node_holder - >::type + __node_holder __construct_node(_A0&& __a0); #ifndef _LIBCPP_HAS_NO_VARIADICS template @@ -1793,11 +1759,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node() template template -typename enable_if -< - is_constructible, _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 -template -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 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 0000000..9a00829 --- /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. +// +//===----------------------------------------------------------------------===// + +// + +// class map + +// mapped_type& operator[](const key_type& k); + +// http://llvm.org/bugs/show_bug.cgi?id=16542 + +#include + +#ifndef _LIBCPP_HAS_NO_VARIADICS + +#include + +#endif + +int main() +{ +#ifndef _LIBCPP_HAS_NO_VARIADICS + using namespace std; + map, 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 3ade69d..9a87bec 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 M; typedef std::pair 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, min_allocator>> M; typedef std::pair 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 e1eb586..bf8173f 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 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, min_allocator>> 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 c91909e..7af4426 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 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, min_allocator>> 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 8dc3195..3f94c03 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 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, min_allocator>> 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 0000000..c319b5c --- /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. +// +//===----------------------------------------------------------------------===// + +// + +// template , class Pred = equal_to, +// class Alloc = allocator>> +// class unordered_map + +// mapped_type& operator[](const key_type& k); + +// http://llvm.org/bugs/show_bug.cgi?id=16542 + +#include + +#ifndef _LIBCPP_HAS_NO_VARIADICS + +#include + +using namespace std; + +struct my_hash +{ + size_t operator()(const tuple&) const {return 0;} +}; + +#endif + +int main() +{ +#ifndef _LIBCPP_HAS_NO_VARIADICS + unordered_map, 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 515b329..a115101 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 C; typedef std::pair 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>> C; typedef std::pair 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 6c2a75a..6d6f331 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 244419d..80453b1 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 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>> 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 576be4e..bad1ee2 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()); -- 2.7.4