Skip to content

Commit cec33fb

Browse files
Add ctor to initialize __value_type and __tree_node_base, and the object of unique_ptr
1 parent ec9317e commit cec33fb

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

libcxx/include/__tree

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,10 @@ public:
649649

650650
_LIBCPP_HIDE_FROM_ABI void __set_parent(pointer __p) { __parent_ = static_cast<__parent_pointer>(__p); }
651651

652-
~__tree_node_base() = delete;
652+
653+
// template <typename... Args> constexpr __tree_node_base(Args && ... args) =default;
654+
__tree_node_base() = default;
655+
~__tree_node_base() = default;
653656
__tree_node_base(__tree_node_base const&) = delete;
654657
__tree_node_base& operator=(__tree_node_base const&) = delete;
655658
};
@@ -664,6 +667,10 @@ public:
664667
_LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; }
665668
// _LIBCPP_HIDE_FROM_ABI static _Tp& __get_value_static(__tree_node * foo) { return (foo->__value_); }
666669

670+
671+
template <typename... Args> constexpr __tree_node(Args && ... args): __value_{std::forward<Args>(args)...} { }
672+
// TODO: libcxx26
673+
// _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_node(__node_value_type && args): __value_{args} { }
667674
~__tree_node() = delete;
668675
__tree_node(__tree_node const&) = delete;
669676
__tree_node& operator=(__tree_node const&) = delete;
@@ -1814,7 +1821,16 @@ __tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&&... __args) {
18141821
static_assert(!__is_tree_value_type<_Args...>::value, "Cannot construct from __value_type");
18151822
__node_allocator& __na = __node_alloc();
18161823
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1817-
__node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), std::forward<_Args>(__args)...);
1824+
// std::__value_type<int, double>
1825+
// __h->__value_;
1826+
// std::addresof(__h->__value_);
1827+
1828+
// __node_traits::construct(__na, std::addressof(__h->__value_), std::forward<_Args>(__args)...);
1829+
// *h is allocated as of yet, but not constructed
1830+
// TODO: -> remove (AFAIK, given only cc in the following needs space: h, h->value and h->value->cc)
1831+
__node_traits::construct(__na, std::addressof(*__h), std::forward<_Args>(__args)...);
1832+
1833+
// __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), std::forward<_Args>(__args)...);
18181834
__h.get_deleter().__value_constructed = true;
18191835
return __h;
18201836
}

libcxx/include/map

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,8 +827,11 @@ public:
827827
return *this;
828828
}
829829

830+
// TODO: libcxx26
831+
template <typename... Args> _LIBCPP_CONSTEXPR_SINCE_CXX26 __value_type(Args && ... args): __cc_{std::forward<Args>(args)...} { }
832+
// constexpr __value_type(value_type && args): __cc_{args} { }
830833
__value_type() = delete;
831-
~__value_type() = delete;
834+
~__value_type() = default;
832835
__value_type(const __value_type&) = delete;
833836
__value_type(__value_type&&) = delete;
834837
};

0 commit comments

Comments
 (0)