Skip to content

Commit 2f689f9

Browse files
use allocator as template arg and allocator_traits, tests passed in cpp26
1 parent 8582025 commit 2f689f9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

libcxx/include/__tree

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,10 +582,16 @@ class _LIBCPP_STANDALONE_DEBUG __tree_node : public __tree_node_base<_VoidPtr> {
582582
public:
583583
using __node_value_type _LIBCPP_NODEBUG = __get_node_value_type_t<_Tp>;
584584

585+
union {
585586
__node_value_type __value_;
587+
};
586588

587589
_LIBCPP_HIDE_FROM_ABI __node_value_type& __get_value() { return __value_; }
588590

591+
template <class _Alloc, class... _Args>
592+
explicit __tree_node(_Alloc& __na, _Args&&... __args) {
593+
allocator_traits<_Alloc>::construct(__na, std::addressof(__value_), std::forward<_Args>(__args)...);
594+
}
589595
~__tree_node() = delete;
590596
__tree_node(__tree_node const&) = delete;
591597
__tree_node& operator=(__tree_node const&) = delete;
@@ -1808,7 +1814,7 @@ typename __tree<_Tp, _Compare, _Allocator>::__node_holder
18081814
__tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&&... __args) {
18091815
__node_allocator& __na = __node_alloc();
18101816
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1811-
__node_traits::construct(__na, std::addressof(__h->__value_), std::forward<_Args>(__args)...);
1817+
std::__construct_at(std::addressof(*__h), __na, std::forward<_Args>(__args)...);
18121818
__h.get_deleter().__value_constructed = true;
18131819
return __h;
18141820
}

0 commit comments

Comments
 (0)