Skip to content

Commit f636597

Browse files
allocator for copy_assign
1 parent 1c46326 commit f636597

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

libcxx/include/__tree

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,10 +1027,15 @@ public:
10271027
__insert_unique_from_orphaned_node(const_iterator __p, __get_node_value_type_t<_Tp>&& __value) {
10281028
// fails here for move_alloc.pass.cpp
10291029
if (__libcpp_is_constant_evaluated()) {
1030-
__node_allocator& __na = __node_alloc();
1031-
key_type __kk;
1032-
__node_traits::construct(__na, std::addressof(__kk), std::move(__value.first));
1033-
__emplace_hint_unique(__p, std::move(__kk), std::move(__value.second));
1030+
1031+
// using __node_value_type = __get_node_value_type_t<value_type>;
1032+
// __get_node_value_type_t<value_type> __tmp(__value.first, __value.second);
1033+
1034+
// __node_allocator& __na = __node_alloc();
1035+
// key_type __kk;
1036+
// __node_traits::construct(__na, std::addressof(__kk), std::move(__value.first));
1037+
// __emplace_hint_unique(__p, std::move(__kk), std::move(__value.second));
1038+
__emplace_hint_unique(__p, std::move(__value.first), std::move(__value.second));
10341039
} else
10351040
{
10361041
__emplace_hint_unique(__p, const_cast<key_type&&>(__value.first), std::move(__value.second));
@@ -1210,8 +1215,8 @@ private:
12101215
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __move_assign_alloc(__tree&, false_type) _NOEXCEPT {}
12111216

12121217
template <class _From, class _ValueT = _Tp, __enable_if_t<__is_tree_value_type<_ValueT>::value, int> = 0>
1213-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static void
1214-
__assign_value(__get_node_value_type_t<value_type>& __lhs, _From&& __rhs) {
1218+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
1219+
__assign_value( __get_node_value_type_t<value_type>& __lhs, _From&& __rhs) {
12151220
using __key_type = __remove_const_t<typename value_type::first_type>;
12161221

12171222
if (__libcpp_is_constant_evaluated()) {
@@ -1223,9 +1228,12 @@ private:
12231228
// todo: use __node_traits::construct
12241229
// __node_allocator& __na = __lhs.__node_alloc();
12251230
// __node_allocator& __na = __rhs.__node_alloc();
1226-
// __node_traits::destroy(__na, std::addressof(__lhs));
1227-
// __node_traits::construct(__na, std::addressof(__lhs), std::move(__tmp));
1228-
new (std::addressof(__lhs))(__node_value_type)(std::move(__tmp));
1231+
__node_allocator& __na = __node_alloc();
1232+
__node_traits::destroy(__na, std::addressof(__lhs));
1233+
1234+
// __node_allocator& __na = __rhs.__node_alloc();
1235+
__node_traits::construct(__na, std::addressof(__lhs), std::move(__tmp));
1236+
// new (std::addressof(__lhs))(__node_value_type)(std::move(__tmp));
12291237
} else {
12301238
// This is technically UB, since the object was constructed as `const`.
12311239
// Clang doesn't optimize on this currently though.
@@ -1235,7 +1243,7 @@ private:
12351243
}
12361244

12371245
template <class _To, class _From, class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type<_ValueT>::value, int> = 0>
1238-
_LIBCPP_HIDE_FROM_ABI static void __assign_value(_To& __lhs, _From&& __rhs) {
1246+
_LIBCPP_HIDE_FROM_ABI void __assign_value(_To& __lhs, _From&& __rhs) {
12391247
__lhs = std::forward<_From>(__rhs);
12401248
}
12411249

0 commit comments

Comments
 (0)