Skip to content

Commit 71e88c8

Browse files
use allocator as template arg and allocator_traits, tests passed in cpp26
1 parent 06e38db commit 71e88c8

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

libcxx/include/__tree

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -562,13 +562,16 @@ class _LIBCPP_STANDALONE_DEBUG __tree_node : public __tree_node_base<_VoidPtr> {
562562
public:
563563
using __node_value_type _LIBCPP_NODEBUG = __get_node_value_type_t<_Tp>;
564564

565+
union {
565566
__node_value_type __value_;
567+
};
566568

567569
_LIBCPP_HIDE_FROM_ABI __node_value_type& __get_value() { return __value_; }
568570

569-
template <class... _Args>
570-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_node(_Args&&... __args)
571-
: __value_(std::forward<_Args>(__args)...) {}
571+
template <class _Alloc, class... _Args>
572+
_LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __tree_node(_Alloc& __na, _Args&&... __args) {
573+
allocator_traits<_Alloc>::construct(__na, std::addressof(__value_), std::forward<_Args>(__args)...);
574+
}
572575
~__tree_node() = delete;
573576
__tree_node(__tree_node const&) = delete;
574577
__tree_node& operator=(__tree_node const&) = delete;
@@ -1882,11 +1885,14 @@ __tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&&... __args) {
18821885
#if _LIBCPP_STD_VER >= 26
18831886
if (__libcpp_is_constant_evaluated()) {
18841887
// note: construction of subobject of object outside its lifetime is not allowed in a constant expression
1885-
std::__construct_at(std::addressof(*__h), std::forward<_Args>(__args)...);
1888+
std::__construct_at(std::addressof(*__h), __na, std::forward<_Args>(__args)...);
1889+
// std::__construct_at(std::addressof(*__h));
1890+
// __node_traits::construct(__na, std::addressof(__h->__value_), std::forward<_Args>(__args)...);
18861891
} else
18871892
#endif
18881893
{
1889-
__node_traits::construct(__na, std::addressof(__h->__value_), std::forward<_Args>(__args)...);
1894+
std::__construct_at(std::addressof(*__h), __na, std::forward<_Args>(__args)...);
1895+
// __node_traits::construct(__na, std::addressof(__h->__value_), std::forward<_Args>(__args)...);
18901896
}
18911897

18921898
__h.get_deleter().__value_constructed = true;

0 commit comments

Comments
 (0)