Skip to content

Commit e57be9e

Browse files
index_rv_key at it again
1 parent f636597 commit e57be9e

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

libcxx/include/__tree

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,15 +1026,12 @@ public:
10261026
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
10271027
__insert_unique_from_orphaned_node(const_iterator __p, __get_node_value_type_t<_Tp>&& __value) {
10281028
// fails here for move_alloc.pass.cpp
1029-
if (__libcpp_is_constant_evaluated()) {
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));
1029+
if (
1030+
(
1031+
_LIBCPP_STD_VER >= 26
1032+
)
1033+
&&
1034+
__libcpp_is_constant_evaluated()) {
10381035
__emplace_hint_unique(__p, std::move(__value.first), std::move(__value.second));
10391036
} else
10401037
{
@@ -1219,21 +1216,22 @@ private:
12191216
__assign_value( __get_node_value_type_t<value_type>& __lhs, _From&& __rhs) {
12201217
using __key_type = __remove_const_t<typename value_type::first_type>;
12211218

1222-
if (__libcpp_is_constant_evaluated()) {
1219+
if (
1220+
(
1221+
_LIBCPP_STD_VER >= 26
1222+
)
1223+
&&
1224+
__libcpp_is_constant_evaluated()) {
12231225
using __node_value_type = __get_node_value_type_t<value_type>;
12241226
__get_node_value_type_t<value_type> __tmp(__rhs.first, __rhs.second);
12251227
// const_cast is not allowed at constexpr time.
12261228
// we get around this by deleting and creating a new node value
1229+
// note: this does not work for `const MoveOnly` keys at constexpr time
12271230
__lhs.~__node_value_type();
1228-
// todo: use __node_traits::construct
1229-
// __node_allocator& __na = __lhs.__node_alloc();
1230-
// __node_allocator& __na = __rhs.__node_alloc();
12311231
__node_allocator& __na = __node_alloc();
12321232
__node_traits::destroy(__na, std::addressof(__lhs));
1233-
1234-
// __node_allocator& __na = __rhs.__node_alloc();
1233+
// Fails here for `std/containers/associative/map/map.cons/move_assign.pass.cpp`
12351234
__node_traits::construct(__na, std::addressof(__lhs), std::move(__tmp));
1236-
// new (std::addressof(__lhs))(__node_value_type)(std::move(__tmp));
12371235
} else {
12381236
// This is technically UB, since the object was constructed as `const`.
12391237
// Clang doesn't optimize on this currently though.
@@ -1899,10 +1897,16 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::__node
18991897
__tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&&... __args) {
19001898
__node_allocator& __na = __node_alloc();
19011899
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1900+
1901+
#if _LIBCPP_STD_VER >= 26
1902+
#else
1903+
#endif
1904+
19021905
// here.... for same_as failure
19031906
// __node_traits::construct(__na, std::addressof(*__h), std::forward<_Args>(__args)...);
1904-
__node_traits::construct(__na, std::addressof(__h->__value_), std::forward<_Args>(__args)...);
19051907
// note: construction of subobject of object outside its lifetime is not allowed in a constant expression
1908+
__node_traits::construct(__na, std::addressof(__h->__value_), std::forward<_Args>(__args)...);
1909+
19061910
__h.get_deleter().__value_constructed = true;
19071911
return __h;
19081912
}

0 commit comments

Comments
 (0)