-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[libc++] Remove some of the type aliases in __hash_table #157114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-libcxx Author: Nikolas Klauser (philnik777) ChangesFull diff: https://github.com/llvm/llvm-project/pull/157114.diff 2 Files Affected:
diff --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table
index 91f660d3491e8..3d7ae26483b13 100644
--- a/libcxx/include/__hash_table
+++ b/libcxx/include/__hash_table
@@ -201,22 +201,11 @@ struct __hash_node_types;
template <class _NodePtr, class _Tp, class _VoidPtr>
struct __hash_node_types<_NodePtr, __hash_node<_Tp, _VoidPtr> > {
- typedef ptrdiff_t difference_type;
- typedef size_t size_type;
-
- typedef __rebind_pointer_t<_NodePtr, void> __void_pointer;
-
typedef typename pointer_traits<_NodePtr>::element_type __node_type;
- typedef _NodePtr __node_pointer;
- typedef __hash_node_base<__node_pointer> __node_base_type;
- typedef __rebind_pointer_t<_NodePtr, __node_base_type> __node_base_pointer;
-
- typedef typename __node_base_type::__next_pointer __next_pointer;
+ typedef typename __hash_node_base<_NodePtr>::__next_pointer __next_pointer;
using __node_value_type _LIBCPP_NODEBUG = __get_hash_node_value_type_t<_Tp>;
- typedef __rebind_pointer_t<_VoidPtr, __node_value_type> __node_value_type_pointer;
- typedef __rebind_pointer_t<_VoidPtr, const __node_value_type> __const_node_value_type_pointer;
private:
static_assert(!is_const<__node_type>::value, "_NodePtr should never be a pointer to const");
@@ -237,13 +226,6 @@ struct __hash_node_types_from_iterator<__hash_local_iterator<_NodePtr> > : __has
template <class _NodePtr>
struct __hash_node_types_from_iterator<__hash_const_local_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {};
-template <class _NodeValueTp, class _VoidPtr>
-struct __make_hash_node_types {
- typedef __hash_node<_NodeValueTp, _VoidPtr> _NodeTp;
- typedef __rebind_pointer_t<_VoidPtr, _NodeTp> _NodePtr;
- typedef __hash_node_types<_NodePtr> type;
-};
-
template <class _NodePtr>
class __hash_iterator {
typedef __hash_node_types<_NodePtr> _NodeTypes;
@@ -255,9 +237,9 @@ class __hash_iterator {
public:
typedef forward_iterator_tag iterator_category;
typedef typename _NodeTypes::__node_value_type value_type;
- typedef typename _NodeTypes::difference_type difference_type;
+ using difference_type = ptrdiff_t;
typedef value_type& reference;
- typedef typename _NodeTypes::__node_value_type_pointer pointer;
+ using pointer = __rebind_pointer_t<_NodePtr, value_type>;
_LIBCPP_HIDE_FROM_ABI __hash_iterator() _NOEXCEPT : __node_(nullptr) {}
@@ -322,9 +304,9 @@ public:
typedef forward_iterator_tag iterator_category;
typedef typename _NodeTypes::__node_value_type value_type;
- typedef typename _NodeTypes::difference_type difference_type;
+ using difference_type = ptrdiff_t;
typedef const value_type& reference;
- typedef typename _NodeTypes::__const_node_value_type_pointer pointer;
+ using pointer = __rebind_pointer_t<_NodePtr, const value_type>;
_LIBCPP_HIDE_FROM_ABI __hash_const_iterator() _NOEXCEPT : __node_(nullptr) {}
@@ -387,9 +369,9 @@ class __hash_local_iterator {
public:
typedef forward_iterator_tag iterator_category;
typedef typename _NodeTypes::__node_value_type value_type;
- typedef typename _NodeTypes::difference_type difference_type;
+ using difference_type = ptrdiff_t;
typedef value_type& reference;
- typedef typename _NodeTypes::__node_value_type_pointer pointer;
+ using pointer = __rebind_pointer_t<_NodePtr, value_type>;
_LIBCPP_HIDE_FROM_ABI __hash_local_iterator() _NOEXCEPT : __node_(nullptr) {}
@@ -465,9 +447,9 @@ public:
typedef forward_iterator_tag iterator_category;
typedef typename _NodeTypes::__node_value_type value_type;
- typedef typename _NodeTypes::difference_type difference_type;
+ using difference_type = ptrdiff_t;
typedef const value_type& reference;
- typedef typename _NodeTypes::__const_node_value_type_pointer pointer;
+ using pointer = __rebind_pointer_t<_ConstNodePtr, const value_type>;
_LIBCPP_HIDE_FROM_ABI __hash_const_local_iterator() _NOEXCEPT : __node_(nullptr) {}
@@ -646,10 +628,8 @@ public:
private:
typedef allocator_traits<allocator_type> __alloc_traits;
- typedef typename __make_hash_node_types<_Tp, typename __alloc_traits::void_pointer>::type _NodeTypes;
public:
- typedef typename _NodeTypes::__node_value_type __node_value_type;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef typename __alloc_traits::pointer pointer;
@@ -657,22 +637,23 @@ public:
#ifndef _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
typedef typename __alloc_traits::size_type size_type;
#else
- typedef typename _NodeTypes::size_type size_type;
+ using size_type = size_t;
#endif
- typedef typename _NodeTypes::difference_type difference_type;
+ using difference_type = ptrdiff_t;
public:
// Create __node
- typedef typename _NodeTypes::__node_type __node;
- typedef __rebind_alloc<__alloc_traits, __node> __node_allocator;
- typedef allocator_traits<__node_allocator> __node_traits;
- typedef typename _NodeTypes::__void_pointer __void_pointer;
- typedef typename _NodeTypes::__node_pointer __node_pointer;
- typedef typename _NodeTypes::__node_pointer __node_const_pointer;
- typedef typename _NodeTypes::__node_base_type __first_node;
- typedef typename _NodeTypes::__node_base_pointer __node_base_pointer;
- typedef typename _NodeTypes::__next_pointer __next_pointer;
+ using __void_pointer = typename __alloc_traits::void_pointer;
+
+ using __node = __hash_node<_Tp, __void_pointer>;
+ using __node_allocator = __rebind_alloc<__alloc_traits, __node>;
+ using __node_traits = allocator_traits<__node_allocator>;
+ using __node_pointer = __rebind_pointer_t<__void_pointer, __node>;
+
+ using __first_node = __hash_node_base<__node_pointer>;
+ using __node_base_pointer = __rebind_pointer_t<__void_pointer, __first_node>;
+ using __next_pointer = __node_base_pointer;
private:
// check for sane allocator pointer rebinding semantics. Rebinding the
diff --git a/libcxx/include/unordered_map b/libcxx/include/unordered_map
index 9b02ecf0393d0..a38e5e0f1b94f 100644
--- a/libcxx/include/unordered_map
+++ b/libcxx/include/unordered_map
@@ -844,8 +844,8 @@ class __hash_map_iterator {
public:
typedef forward_iterator_tag iterator_category;
- using value_type = typename _HashIterator::value_type;
- typedef typename _NodeTypes::difference_type difference_type;
+ using value_type = typename _HashIterator::value_type;
+ using difference_type = ptrdiff_t;
typedef value_type& reference;
using pointer = typename _HashIterator::pointer;
@@ -895,8 +895,8 @@ class __hash_map_const_iterator {
public:
typedef forward_iterator_tag iterator_category;
- using value_type = typename _HashIterator::value_type;
- typedef typename _NodeTypes::difference_type difference_type;
+ using value_type = typename _HashIterator::value_type;
+ using difference_type = ptrdiff_t;
typedef const value_type& reference;
using pointer = typename _HashIterator::pointer;
@@ -972,9 +972,6 @@ private:
__table __table_;
- typedef typename __table::_NodeTypes _NodeTypes;
- typedef typename __table::__node_pointer __node_pointer;
- typedef typename __table::__node_const_pointer __node_const_pointer;
typedef typename __table::__node_traits __node_traits;
typedef typename __table::__node_allocator __node_allocator;
typedef typename __table::__node __node;
@@ -1743,12 +1740,8 @@ private:
__table __table_;
- typedef typename __table::_NodeTypes _NodeTypes;
typedef typename __table::__node_traits __node_traits;
- typedef typename __table::__node_allocator __node_allocator;
typedef typename __table::__node __node;
- typedef __hash_map_node_destructor<__node_allocator> _Dp;
- typedef unique_ptr<__node, _Dp> __node_holder;
typedef allocator_traits<allocator_type> __alloc_traits;
static_assert(is_same<typename __node_traits::size_type, typename __alloc_traits::size_type>::value,
"Allocator uses different size_type for different types");
|
b64017b
to
8008625
Compare
frederick-vs-ja
approved these changes
Sep 9, 2025
ldionne
approved these changes
Sep 9, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.