diff --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table index 49e2fccfd055..ef487fb06dd5 100644 --- a/libcxx/include/__hash_table +++ b/libcxx/include/__hash_table @@ -19,7 +19,6 @@ #include <__cstddef/ptrdiff_t.h> #include <__cstddef/size_t.h> #include <__functional/hash.h> -#include <__fwd/pair.h> #include <__iterator/iterator_traits.h> #include <__math/rounding_functions.h> #include <__memory/addressof.h> @@ -1043,22 +1042,15 @@ private: _LIBCPP_HIDE_FROM_ABI __next_pointer __detach() _NOEXCEPT; - template ::value || __is_pair_v<_ValueT>, int> = 0> + template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI void __assign_value(__get_hash_node_value_type_t<_Tp>& __lhs, _From&& __rhs) { // This is technically UB, since the object was constructed as `const`. // Clang doesn't optimize on this currently though. - // - // The enable_if check for __is_pair_v is only needed to support - // __gnu_cxx::hash_map and may be removed if hash_map is removed. - const_cast<__remove_const_t&>(__lhs.first) = std::forward<_From>(__rhs).first; - __lhs.second = std::forward<_From>(__rhs).second; + const_cast(__lhs.first) = const_cast<__copy_cvref_t<_From, key_type>&&>(__rhs.first); + __lhs.second = std::forward<_From>(__rhs).second; } - template ::value && !__is_pair_v<_ValueT>, int> = 0> + template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI void __assign_value(_Tp& __lhs, _From&& __rhs) { __lhs = std::forward<_From>(__rhs); } diff --git a/libcxx/include/ext/hash_map b/libcxx/include/ext/hash_map index 7df44370df96..09c981131ff9 100644 --- a/libcxx/include/ext/hash_map +++ b/libcxx/include/ext/hash_map @@ -426,10 +426,12 @@ public: typedef const value_type& const_reference; private: - typedef __hash_map_hasher __hasher; - typedef __hash_map_equal __key_equal; + typedef std::pair __value_type; + typedef __hash_map_hasher<__value_type, hasher> __hasher; + typedef __hash_map_equal<__value_type, key_equal> __key_equal; + typedef std::__rebind_alloc, __value_type> __allocator_type; - typedef std::__hash_table __table; + typedef std::__hash_table<__value_type, __hasher, __key_equal, __allocator_type> __table; __table __table_; @@ -575,7 +577,7 @@ typename hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(const key_type& __k) { __node_allocator& __na = __table_.__node_alloc(); __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, const_cast<_Key*>(std::addressof(__h->__get_value().first)), __k); + __node_traits::construct(__na, std::addressof(__h->__get_value().first), __k); __h.get_deleter().__first_constructed = true; __node_traits::construct(__na, std::addressof(__h->__get_value().second)); __h.get_deleter().__second_constructed = true; @@ -645,10 +647,12 @@ public: typedef const value_type& const_reference; private: - typedef __hash_map_hasher __hasher; - typedef __hash_map_equal __key_equal; + typedef std::pair __value_type; + typedef __hash_map_hasher<__value_type, hasher> __hasher; + typedef __hash_map_equal<__value_type, key_equal> __key_equal; + typedef std::__rebind_alloc, __value_type> __allocator_type; - typedef std::__hash_table __table; + typedef std::__hash_table<__value_type, __hasher, __key_equal, __allocator_type> __table; __table __table_; diff --git a/libcxx/test/extensions/gnu/hash_map/copy.pass.cpp b/libcxx/test/extensions/gnu/hash_map/copy.pass.cpp index ca489e8c1c62..65b8debda067 100644 --- a/libcxx/test/extensions/gnu/hash_map/copy.pass.cpp +++ b/libcxx/test/extensions/gnu/hash_map/copy.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// ADDITIONAL_COMPILE_FLAGS: -Wno-deprecated -Wno-deprecated-copy +// ADDITIONAL_COMPILE_FLAGS: -Wno-deprecated // hash_map::hash_map(const hash_map&) @@ -23,9 +23,5 @@ int main(int, char**) { assert(map2.size() == 2); - map.insert(std::make_pair(3, 1)); - map2 = map; - assert(map2.size() == 3); - return 0; } diff --git a/libcxx/test/extensions/gnu/hash_map/non_standard_layout.pass.cpp b/libcxx/test/extensions/gnu/hash_map/non_standard_layout.pass.cpp deleted file mode 100644 index 4c8403f5ad74..000000000000 --- a/libcxx/test/extensions/gnu/hash_map/non_standard_layout.pass.cpp +++ /dev/null @@ -1,16 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// ADDITIONAL_COMPILE_FLAGS: -Wno-deprecated -#include - -int main(int, char**) { - __gnu_cxx::hash_map m; - auto it = m.insert(std::make_pair("foo", "bar")).first; - return it->first == nullptr; -} diff --git a/libcxx/test/extensions/gnu/hash_multimap/non_standard_layout.pass.cpp b/libcxx/test/extensions/gnu/hash_multimap/non_standard_layout.pass.cpp deleted file mode 100644 index c8b8a3c63cf5..000000000000 --- a/libcxx/test/extensions/gnu/hash_multimap/non_standard_layout.pass.cpp +++ /dev/null @@ -1,16 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// ADDITIONAL_COMPILE_FLAGS: -Wno-deprecated -#include - -int main(int, char**) { - __gnu_cxx::hash_multimap m; - auto it = m.insert(std::make_pair("foo", "bar")); - return it->first == nullptr; -}