@@ -1027,14 +1027,12 @@ public:
1027
1027
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
1028
1028
__insert_unique_from_orphaned_node (const_iterator __p, __get_node_value_type_t <_Tp>&& __value) {
1029
1029
// fails here for move_alloc.pass.cpp
1030
- if (
1031
- (
1032
- _LIBCPP_STD_VER >= 26
1033
- )
1034
- &&
1035
- __libcpp_is_constant_evaluated ()) {
1030
+
1031
+ #if _LIBCPP_STD_VER >= 26
1032
+ if (__libcpp_is_constant_evaluated ()) {
1036
1033
__emplace_hint_unique (__p, std::move (__value.first ), std::move (__value.second ));
1037
1034
} else
1035
+ #endif
1038
1036
{
1039
1037
__emplace_hint_unique (__p, const_cast <key_type&&>(__value.first ), std::move (__value.second ));
1040
1038
}
@@ -1212,6 +1210,35 @@ private:
1212
1210
}
1213
1211
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __move_assign_alloc (__tree&, false_type) _NOEXCEPT {}
1214
1212
1213
+
1214
+ // todo; mark consteval?
1215
+ #ifdef FAKE_VINAY
1216
+
1217
+ template <class _From , class _ValueT = _Tp,
1218
+ __enable_if_t <__is_tree_value_type<_ValueT>::value, int > = 0
1219
+ , __enable_if_t < ! is_copy_constructible_v< typename _From::first_type >, int > = 0
1220
+ >
1221
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __move_from_value_type (
1222
+ __get_node_value_type_t <value_type>& __lhs, _From&& __rhs/* , false_type*/ ) _NOEXCEPT {
1223
+ (void )__lhs;
1224
+ (void )__rhs;
1225
+ static_assert (false , " Can not move from a pair<const T, T>" );
1226
+ }
1227
+
1228
+ template <class _From , class _ValueT = _Tp,
1229
+ __enable_if_t <__is_tree_value_type<_ValueT>::value, int > = 0
1230
+
1231
+ // Check if first type can be copy constructed
1232
+ , __enable_if_t < is_copy_constructible_v< typename _From::first_type >, int > = 0
1233
+ >
1234
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __move_from_value_type (
1235
+ __get_node_value_type_t <value_type>& __lhs, _From&& __rhs/* , true_type*/ ) _NOEXCEPT {
1236
+
1237
+ }
1238
+ #endif
1239
+
1240
+
1241
+
1215
1242
template <class _From , class _ValueT = _Tp, __enable_if_t <__is_tree_value_type<_ValueT>::value, int > = 0 >
1216
1243
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
1217
1244
__assign_value ( __get_node_value_type_t <value_type>& __lhs, _From&& __rhs) {
@@ -1226,16 +1253,29 @@ error: no matching constructor for initialization of '__get_node_value_type_t<va
1226
1253
# | 1225 | __get_node_value_type_t<value_type> __tmp(__rhs.first, __rhs.second);
1227
1254
*/
1228
1255
if (__libcpp_is_constant_evaluated ()) {
1256
+ // __move_from_value_type(__lhs, __rhs
1257
+ // , integral_constant<bool, is_copy_constructible_v<_From> >()
1258
+ // );
1259
+
1229
1260
using __node_value_type = __get_node_value_type_t <value_type>;
1230
1261
__get_node_value_type_t <value_type> __tmp (__rhs.first , __rhs.second );
1262
+ // __get_node_value_type_t<value_type> __tmp(__rhs);
1263
+
1231
1264
// const_cast is not allowed at constexpr time.
1232
- // we get around this by deleting and creating a new node value
1265
+ // we get around this by deleting __lhs and creating a new node in-place
1266
+ // to avoid const_cast -ing __lhs.first
1267
+
1233
1268
// note: this does not work for `const MoveOnly` keys at constexpr time
1234
1269
1235
1270
// __lhs.~__node_value_type();
1236
1271
__node_allocator& __na = __node_alloc ();
1237
1272
__node_traits::destroy (__na, std::addressof (__lhs));
1238
1273
__node_traits::construct (__na, std::addressof (__lhs), std::move (__tmp));
1274
+
1275
+
1276
+
1277
+
1278
+
1239
1279
} else
1240
1280
#endif
1241
1281
{
@@ -1915,14 +1955,13 @@ __tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&&... __args) {
1915
1955
// for container_test_types.h
1916
1956
// but I don't know how to placement new to avoid instantiation
1917
1957
1918
- } else {
1958
+ } else
1919
1959
#endif
1920
-
1960
+ {
1921
1961
__node_traits::construct (__na, std::addressof (__h->__value_ ), std::forward<_Args>(__args)...);
1922
-
1923
-
1924
- #if _LIBCPP_STD_VER >= 26
1925
1962
}
1963
+ #if _LIBCPP_STD_VER >= 26
1964
+
1926
1965
#endif
1927
1966
1928
1967
0 commit comments