@@ -1026,15 +1026,12 @@ public:
1026
1026
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
1027
1027
__insert_unique_from_orphaned_node (const_iterator __p, __get_node_value_type_t <_Tp>&& __value) {
1028
1028
// 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 ()) {
1038
1035
__emplace_hint_unique (__p, std::move (__value.first ), std::move (__value.second ));
1039
1036
} else
1040
1037
{
@@ -1219,21 +1216,22 @@ private:
1219
1216
__assign_value ( __get_node_value_type_t <value_type>& __lhs, _From&& __rhs) {
1220
1217
using __key_type = __remove_const_t <typename value_type::first_type>;
1221
1218
1222
- if (__libcpp_is_constant_evaluated ()) {
1219
+ if (
1220
+ (
1221
+ _LIBCPP_STD_VER >= 26
1222
+ )
1223
+ &&
1224
+ __libcpp_is_constant_evaluated ()) {
1223
1225
using __node_value_type = __get_node_value_type_t <value_type>;
1224
1226
__get_node_value_type_t <value_type> __tmp (__rhs.first , __rhs.second );
1225
1227
// const_cast is not allowed at constexpr time.
1226
1228
// 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
1227
1230
__lhs.~__node_value_type ();
1228
- // todo: use __node_traits::construct
1229
- // __node_allocator& __na = __lhs.__node_alloc();
1230
- // __node_allocator& __na = __rhs.__node_alloc();
1231
1231
__node_allocator& __na = __node_alloc ();
1232
1232
__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`
1235
1234
__node_traits::construct (__na, std::addressof (__lhs), std::move (__tmp));
1236
- // new (std::addressof(__lhs))(__node_value_type)(std::move(__tmp));
1237
1235
} else {
1238
1236
// This is technically UB, since the object was constructed as `const`.
1239
1237
// Clang doesn't optimize on this currently though.
@@ -1899,10 +1897,16 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::__node
1899
1897
__tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&&... __args) {
1900
1898
__node_allocator& __na = __node_alloc ();
1901
1899
__node_holder __h (__node_traits::allocate (__na, 1 ), _Dp (__na));
1900
+
1901
+ #if _LIBCPP_STD_VER >= 26
1902
+ #else
1903
+ #endif
1904
+
1902
1905
// here.... for same_as failure
1903
1906
// __node_traits::construct(__na, std::addressof(*__h), std::forward<_Args>(__args)...);
1904
- __node_traits::construct (__na, std::addressof (__h->__value_ ), std::forward<_Args>(__args)...);
1905
1907
// 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
+
1906
1910
__h.get_deleter ().__value_constructed = true ;
1907
1911
return __h;
1908
1912
}
0 commit comments