Skip to content

Commit 41fb566

Browse files
author
git apple-llvm automerger
committed
Merge commit 'b04f6f83f438' from llvm.org/main into next
2 parents 21a4ed8 + b04f6f8 commit 41fb566

File tree

1 file changed

+25
-46
lines changed

1 file changed

+25
-46
lines changed

libcxx/include/__tree

Lines changed: 25 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -862,9 +862,21 @@ public:
862862
using const_iterator = __tree_const_iterator<_Tp, __node_pointer, difference_type>;
863863

864864
_LIBCPP_HIDE_FROM_ABI explicit __tree(const value_compare& __comp) _NOEXCEPT_(
865-
is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_copy_constructible<value_compare>::value);
866-
_LIBCPP_HIDE_FROM_ABI explicit __tree(const allocator_type& __a);
867-
_LIBCPP_HIDE_FROM_ABI __tree(const value_compare& __comp, const allocator_type& __a);
865+
is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_copy_constructible<value_compare>::value)
866+
: __size_(0), __value_comp_(__comp) {
867+
__begin_node_ = __end_node();
868+
}
869+
870+
_LIBCPP_HIDE_FROM_ABI explicit __tree(const allocator_type& __a)
871+
: __begin_node_(), __node_alloc_(__node_allocator(__a)), __size_(0) {
872+
__begin_node_ = __end_node();
873+
}
874+
875+
_LIBCPP_HIDE_FROM_ABI __tree(const value_compare& __comp, const allocator_type& __a)
876+
: __begin_node_(), __node_alloc_(__node_allocator(__a)), __size_(0), __value_comp_(__comp) {
877+
__begin_node_ = __end_node();
878+
}
879+
868880
_LIBCPP_HIDE_FROM_ABI __tree(const __tree& __t);
869881
_LIBCPP_HIDE_FROM_ABI __tree& operator=(const __tree& __t);
870882
template <class _ForwardIterator>
@@ -874,13 +886,20 @@ public:
874886
_LIBCPP_HIDE_FROM_ABI __tree(__tree&& __t) _NOEXCEPT_(
875887
is_nothrow_move_constructible<__node_allocator>::value&& is_nothrow_move_constructible<value_compare>::value);
876888
_LIBCPP_HIDE_FROM_ABI __tree(__tree&& __t, const allocator_type& __a);
889+
877890
_LIBCPP_HIDE_FROM_ABI __tree& operator=(__tree&& __t)
878891
_NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value &&
879892
((__node_traits::propagate_on_container_move_assignment::value &&
880893
is_nothrow_move_assignable<__node_allocator>::value) ||
881-
allocator_traits<__node_allocator>::is_always_equal::value));
894+
allocator_traits<__node_allocator>::is_always_equal::value)) {
895+
__move_assign(__t, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>());
896+
return *this;
897+
}
882898

883-
_LIBCPP_HIDE_FROM_ABI ~__tree();
899+
_LIBCPP_HIDE_FROM_ABI ~__tree() {
900+
static_assert(is_copy_constructible<value_compare>::value, "Comparator must be copy-constructible.");
901+
destroy(__root());
902+
}
884903

885904
_LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__begin_node_); }
886905
_LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return const_iterator(__begin_node_); }
@@ -1204,7 +1223,7 @@ private:
12041223
_LIBCPP_HIDE_FROM_ABI __node_holder __construct_node(_Args&&... __args);
12051224

12061225
// TODO: Make this _LIBCPP_HIDE_FROM_ABI
1207-
_LIBCPP_HIDDEN void destroy(__node_pointer __nd) _NOEXCEPT;
1226+
_LIBCPP_HIDDEN void destroy(__node_pointer __nd) _NOEXCEPT { (__tree_deleter(__node_alloc_))(__nd); }
12081227

12091228
_LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, false_type);
12101229
_LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, true_type) _NOEXCEPT_(
@@ -1373,25 +1392,6 @@ private:
13731392
}
13741393
};
13751394

1376-
template <class _Tp, class _Compare, class _Allocator>
1377-
__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp) _NOEXCEPT_(
1378-
is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_copy_constructible<value_compare>::value)
1379-
: __size_(0), __value_comp_(__comp) {
1380-
__begin_node_ = __end_node();
1381-
}
1382-
1383-
template <class _Tp, class _Compare, class _Allocator>
1384-
__tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a)
1385-
: __begin_node_(), __node_alloc_(__node_allocator(__a)), __size_(0) {
1386-
__begin_node_ = __end_node();
1387-
}
1388-
1389-
template <class _Tp, class _Compare, class _Allocator>
1390-
__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp, const allocator_type& __a)
1391-
: __begin_node_(), __node_alloc_(__node_allocator(__a)), __size_(0), __value_comp_(__comp) {
1392-
__begin_node_ = __end_node();
1393-
}
1394-
13951395
// Precondition: __size_ != 0
13961396
template <class _Tp, class _Compare, class _Allocator>
13971397
typename __tree<_Tp, _Compare, _Allocator>::__node_pointer
@@ -1588,27 +1588,6 @@ void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type) {
15881588
}
15891589
}
15901590

1591-
template <class _Tp, class _Compare, class _Allocator>
1592-
__tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(__tree&& __t)
1593-
_NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value &&
1594-
((__node_traits::propagate_on_container_move_assignment::value &&
1595-
is_nothrow_move_assignable<__node_allocator>::value) ||
1596-
allocator_traits<__node_allocator>::is_always_equal::value)) {
1597-
__move_assign(__t, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>());
1598-
return *this;
1599-
}
1600-
1601-
template <class _Tp, class _Compare, class _Allocator>
1602-
__tree<_Tp, _Compare, _Allocator>::~__tree() {
1603-
static_assert(is_copy_constructible<value_compare>::value, "Comparator must be copy-constructible.");
1604-
destroy(__root());
1605-
}
1606-
1607-
template <class _Tp, class _Compare, class _Allocator>
1608-
void __tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT {
1609-
(__tree_deleter(__node_alloc_))(__nd);
1610-
}
1611-
16121591
template <class _Tp, class _Compare, class _Allocator>
16131592
void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t)
16141593
#if _LIBCPP_STD_VER <= 11

0 commit comments

Comments
 (0)