summaryrefslogtreecommitdiffstats
path: root/lib/libcxx/include/__hash_table
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libcxx/include/__hash_table')
-rw-r--r--lib/libcxx/include/__hash_table136
1 files changed, 125 insertions, 11 deletions
diff --git a/lib/libcxx/include/__hash_table b/lib/libcxx/include/__hash_table
index 3f430af1283..c77de961be6 100644
--- a/lib/libcxx/include/__hash_table
+++ b/lib/libcxx/include/__hash_table
@@ -32,13 +32,8 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-#ifndef _LIBCPP_CXX03_LANG
-template <class _Key, class _Tp>
-union __hash_value_type;
-#else
template <class _Key, class _Tp>
struct __hash_value_type;
-#endif
template <class _Key, class _Cp, class _Hash,
bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value>
@@ -172,7 +167,7 @@ struct __hash_key_value_types {
}
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
- static __container_value_type&& __move(__node_value_type& __v) {
+ static __container_value_type&& __move(__node_value_type& __v) {
return _VSTD::move(__v);
}
#endif
@@ -184,7 +179,6 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > {
typedef _Tp mapped_type;
typedef __hash_value_type<_Key, _Tp> __node_value_type;
typedef pair<const _Key, _Tp> __container_value_type;
- typedef pair<_Key, _Tp> __nc_value_type;
typedef __container_value_type __map_value_type;
static const bool __is_map = true;
@@ -198,7 +192,7 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > {
static typename enable_if<__is_same_uncvref<_Up, __node_value_type>::value,
__container_value_type const&>::type
__get_value(_Up& __t) {
- return __t.__cc;
+ return __t.__get_value();
}
template <class _Up>
@@ -211,12 +205,12 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > {
_LIBCPP_INLINE_VISIBILITY
static __container_value_type* __get_ptr(__node_value_type& __n) {
- return _VSTD::addressof(__n.__cc);
+ return _VSTD::addressof(__n.__get_value());
}
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
- static __nc_value_type&& __move(__node_value_type& __v) {
- return _VSTD::move(__v.__nc);
+ static pair<key_type&&, mapped_type&&> __move(__node_value_type& __v) {
+ return __v.__move();
}
#endif
@@ -865,6 +859,17 @@ public:
template <class> friend class __hash_map_node_destructor;
};
+#if _LIBCPP_STD_VER > 14
+template <class _NodeType, class _Alloc>
+struct __generic_container_node_destructor;
+
+template <class _Tp, class _VoidPtr, class _Alloc>
+struct __generic_container_node_destructor<__hash_node<_Tp, _VoidPtr>, _Alloc>
+ : __hash_node_destructor<_Alloc>
+{
+ using __hash_node_destructor<_Alloc>::__hash_node_destructor;
+};
+#endif
#ifndef _LIBCPP_CXX03_LANG
template <class _Key, class _Hash, class _Equal, class _Alloc>
@@ -1157,6 +1162,30 @@ public:
return __emplace_unique_key_args(_NodeTypes::__get_key(__x), __x);
}
+#if _LIBCPP_STD_VER > 14
+ template <class _NodeHandle, class _InsertReturnType>
+ _LIBCPP_INLINE_VISIBILITY
+ _InsertReturnType __node_handle_insert_unique(_NodeHandle&& __nh);
+ template <class _NodeHandle>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __node_handle_insert_unique(const_iterator __hint,
+ _NodeHandle&& __nh);
+
+ template <class _NodeHandle>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __node_handle_insert_multi(_NodeHandle&& __nh);
+ template <class _NodeHandle>
+ _LIBCPP_INLINE_VISIBILITY
+ iterator __node_handle_insert_multi(const_iterator __hint, _NodeHandle&& __nh);
+
+ template <class _NodeHandle>
+ _LIBCPP_INLINE_VISIBILITY
+ _NodeHandle __node_handle_extract(key_type const& __key);
+ template <class _NodeHandle>
+ _LIBCPP_INLINE_VISIBILITY
+ _NodeHandle __node_handle_extract(const_iterator __it);
+#endif
+
void clear() _NOEXCEPT;
void rehash(size_type __n);
_LIBCPP_INLINE_VISIBILITY void reserve(size_type __n)
@@ -2132,6 +2161,91 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const_iterator __p,
#endif // _LIBCPP_CXX03_LANG
+#if _LIBCPP_STD_VER > 14
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _NodeHandle, class _InsertReturnType>
+_LIBCPP_INLINE_VISIBILITY
+_InsertReturnType
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_unique(
+ _NodeHandle&& __nh)
+{
+ if (__nh.empty())
+ return _InsertReturnType{end(), false, _NodeHandle()};
+ pair<iterator, bool> __result = __node_insert_unique(__nh.__ptr_);
+ if (__result.second)
+ __nh.__release();
+ return _InsertReturnType{__result.first, __result.second, _VSTD::move(__nh)};
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_unique(
+ const_iterator, _NodeHandle&& __nh)
+{
+ if (__nh.empty())
+ return end();
+ pair<iterator, bool> __result = __node_insert_unique(__nh.__ptr_);
+ if (__result.second)
+ __nh.__release();
+ return __result.first;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+_NodeHandle
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_extract(
+ key_type const& __key)
+{
+ iterator __i = find(__key);
+ if (__i == end())
+ return _NodeHandle();
+ return __node_handle_extract<_NodeHandle>(__i);
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+_NodeHandle
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_extract(
+ const_iterator __p)
+{
+ allocator_type __alloc(__node_alloc());
+ return _NodeHandle(remove(__p).release(), __alloc);
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_multi(
+ _NodeHandle&& __nh)
+{
+ if (__nh.empty())
+ return end();
+ iterator __result = __node_insert_multi(__nh.__ptr_);
+ __nh.__release();
+ return __result;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _NodeHandle>
+_LIBCPP_INLINE_VISIBILITY
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_multi(
+ const_iterator __hint, _NodeHandle&& __nh)
+{
+ if (__nh.empty())
+ return end();
+ iterator __result = __node_insert_multi(__hint, __nh.__ptr_);
+ __nh.__release();
+ return __result;
+}
+
+#endif // _LIBCPP_STD_VER > 14
+
template <class _Tp, class _Hash, class _Equal, class _Alloc>
void
__hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n)