Skip to content

Commit 89eef94

Browse files
authored
[libc++] Only accept __trees inside the __tree merge functions (#163521)
This makes it clear what we actually expect in these functions, making the whole thing a bit more readable.
1 parent cf7929f commit 89eef94

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

libcxx/include/__tree

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,15 +1119,15 @@ public:
11191119
_LIBCPP_HIDE_FROM_ABI _InsertReturnType __node_handle_insert_unique(_NodeHandle&&);
11201120
template <class _NodeHandle>
11211121
_LIBCPP_HIDE_FROM_ABI iterator __node_handle_insert_unique(const_iterator, _NodeHandle&&);
1122-
template <class _Tree>
1123-
_LIBCPP_HIDE_FROM_ABI void __node_handle_merge_unique(_Tree& __source);
1122+
template <class _Comp2>
1123+
_LIBCPP_HIDE_FROM_ABI void __node_handle_merge_unique(__tree<_Tp, _Comp2, _Allocator>& __source);
11241124

11251125
template <class _NodeHandle>
11261126
_LIBCPP_HIDE_FROM_ABI iterator __node_handle_insert_multi(_NodeHandle&&);
11271127
template <class _NodeHandle>
11281128
_LIBCPP_HIDE_FROM_ABI iterator __node_handle_insert_multi(const_iterator, _NodeHandle&&);
1129-
template <class _Tree>
1130-
_LIBCPP_HIDE_FROM_ABI void __node_handle_merge_multi(_Tree& __source);
1129+
template <class _Comp2>
1130+
_LIBCPP_HIDE_FROM_ABI void __node_handle_merge_multi(__tree<_Tp, _Comp2, _Allocator>& __source);
11311131

11321132
template <class _NodeHandle>
11331133
_LIBCPP_HIDE_FROM_ABI _NodeHandle __node_handle_extract(key_type const&);
@@ -2020,11 +2020,10 @@ _LIBCPP_HIDE_FROM_ABI _NodeHandle __tree<_Tp, _Compare, _Allocator>::__node_hand
20202020
}
20212021

20222022
template <class _Tp, class _Compare, class _Allocator>
2023-
template <class _Tree>
2024-
_LIBCPP_HIDE_FROM_ABI void __tree<_Tp, _Compare, _Allocator>::__node_handle_merge_unique(_Tree& __source) {
2025-
static_assert(is_same<typename _Tree::__node_pointer, __node_pointer>::value, "");
2026-
2027-
for (typename _Tree::iterator __i = __source.begin(); __i != __source.end();) {
2023+
template <class _Comp2>
2024+
_LIBCPP_HIDE_FROM_ABI void
2025+
__tree<_Tp, _Compare, _Allocator>::__node_handle_merge_unique(__tree<_Tp, _Comp2, _Allocator>& __source) {
2026+
for (iterator __i = __source.begin(); __i != __source.end();) {
20282027
__node_pointer __src_ptr = __i.__get_np();
20292028
auto [__parent, __child] = __find_equal(__src_ptr->__get_value());
20302029
++__i;
@@ -2065,11 +2064,10 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(const_iterator __h
20652064
}
20662065

20672066
template <class _Tp, class _Compare, class _Allocator>
2068-
template <class _Tree>
2069-
_LIBCPP_HIDE_FROM_ABI void __tree<_Tp, _Compare, _Allocator>::__node_handle_merge_multi(_Tree& __source) {
2070-
static_assert(is_same<typename _Tree::__node_pointer, __node_pointer>::value, "");
2071-
2072-
for (typename _Tree::iterator __i = __source.begin(); __i != __source.end();) {
2067+
template <class _Comp2>
2068+
_LIBCPP_HIDE_FROM_ABI void
2069+
__tree<_Tp, _Compare, _Allocator>::__node_handle_merge_multi(__tree<_Tp, _Comp2, _Allocator>& __source) {
2070+
for (iterator __i = __source.begin(); __i != __source.end();) {
20732071
__node_pointer __src_ptr = __i.__get_np();
20742072
__end_node_pointer __parent;
20752073
__node_base_pointer& __child = __find_leaf_high(__parent, __src_ptr->__get_value());

0 commit comments

Comments
 (0)