@@ -1218,67 +1218,45 @@ private:
1218
1218
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __move_assign_alloc (__tree&, false_type) _NOEXCEPT {}
1219
1219
1220
1220
1221
- // todo; mark consteval?
1222
- // #ifdef FAKE_VINAY
1221
+ // todo; remove
1222
+ #ifdef FAKE_VINAY
1223
1223
1224
1224
template <class _From , class _ValueT = _Tp,
1225
1225
__enable_if_t <__is_tree_value_type_v<_ValueT>, int > = 0
1226
1226
1227
- // , typename = std::enable_if_t<
1228
- // !std::is_copy_constructible_v<
1229
- // std::remove_cvref_t<decltype(std::declval<_From>().first)>
1230
- // >
1231
- // >
1227
+ , typename = std::enable_if_t <
1228
+ !std::is_copy_constructible_v<
1229
+ std::remove_cvref_t <decltype (std::declval<_From>().first)>
1230
+ >
1231
+ >
1232
1232
>
1233
- requires (!std::is_copy_constructible_v<
1234
- std::remove_cvref_t <decltype (std::declval<_From>().first)>
1235
- >)
1233
+ // requires (!std::is_copy_constructible_v<
1234
+ // std::remove_cvref_t<decltype(std::declval<_From>().first)>
1235
+ // >)
1236
1236
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __move_from_value_type (
1237
1237
__get_node_value_type_t <value_type>& __lhs, _From&& __rhs/* , false_type*/ ) _NOEXCEPT {
1238
- (void )__lhs;
1239
- (void )__rhs;
1240
- // static_assert(false, "Can not move from a pair<const T, U>");
1241
- // TODO: how do I flag this code to NOT run at compile time?
1242
- // Using static_assert means this can't compile _at all_, regardless of whether this code is actually going to execute at compile time or not
1243
1238
}
1244
1239
1245
1240
template <class _From , class _ValueT = _Tp,
1246
1241
__enable_if_t <__is_tree_value_type_v<_ValueT>, int > = 0
1247
1242
1248
1243
// Check if first type can be copy constructed
1249
1244
1250
- // , typename = std::enable_if_t<
1251
- // std::is_copy_constructible_v<
1252
- // std::remove_cvref_t<decltype(std::declval<_From>().first)>
1253
- // >
1254
- // >
1245
+ , typename = std::enable_if_t <
1246
+ std::is_copy_constructible_v<
1247
+ std::remove_cvref_t <decltype (std::declval<_From>().first)>
1248
+ >
1249
+ >
1255
1250
>
1256
- requires ( std::is_copy_constructible_v<
1257
- std::remove_cvref_t <decltype (std::declval<_From>().first)>
1258
- >)
1251
+ // requires ( std::is_copy_constructible_v<
1252
+ // std::remove_cvref_t<decltype(std::declval<_From>().first)>
1253
+ // >)
1259
1254
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __move_from_value_type (
1260
1255
__get_node_value_type_t <value_type>& __lhs, _From&& __rhs/* , true_type*/ ) _NOEXCEPT {
1261
1256
1262
1257
1263
- // const_cast is not allowed at constexpr time.
1264
- // we get around this by deleting __lhs and creating a new node in-place
1265
- // to avoid const_cast -ing __lhs.first
1266
-
1267
- // note: this does not work for `const MoveOnly` keys at constexpr time
1268
-
1269
-
1270
- __node_allocator& __na = __node_alloc ();
1271
- __node_traits::destroy (__na, std::addressof (__lhs));
1272
-
1273
- // __get_node_value_type_t<value_type> __tmp(__rhs);
1274
- using __node_value_type = __get_node_value_type_t <value_type>;
1275
- __node_value_type __tmp (__rhs.first , __rhs.second );
1276
- __node_traits::construct (__na, std::addressof (__lhs), std::move (__tmp));
1277
-
1278
-
1279
-
1280
1258
}
1281
- // #endif
1259
+ #endif
1282
1260
1283
1261
1284
1262
@@ -1295,9 +1273,37 @@ error: no matching constructor for initialization of '__get_node_value_type_t<va
1295
1273
# | 1225 | __get_node_value_type_t<value_type> __tmp(__rhs.first, __rhs.second);
1296
1274
*/
1297
1275
if (__libcpp_is_constant_evaluated ()) {
1298
- __move_from_value_type (__lhs, __rhs
1276
+ // __move_from_value_type(__lhs, __rhs
1299
1277
// , integral_constant<bool, is_copy_constructible_v<_From> >()
1300
- );
1278
+ // );
1279
+
1280
+ if constexpr (integral_constant<bool , is_copy_constructible_v<_From> >()) {
1281
+
1282
+ // const_cast is not allowed at constexpr time.
1283
+ // we get around this by deleting __lhs and creating a new node in-place
1284
+ // to avoid const_cast -ing __lhs.first
1285
+
1286
+ // note: this does not work for `const MoveOnly` keys at constexpr time
1287
+
1288
+
1289
+ __node_allocator& __na = __node_alloc ();
1290
+ __node_traits::destroy (__na, std::addressof (__lhs));
1291
+
1292
+ // __get_node_value_type_t<value_type> __tmp(__rhs);
1293
+ using __node_value_type = __get_node_value_type_t <value_type>;
1294
+ __node_value_type __tmp (__rhs.first , __rhs.second );
1295
+ __node_traits::construct (__na, std::addressof (__lhs), std::move (__tmp));
1296
+
1297
+
1298
+ } else {
1299
+
1300
+ // (void)__lhs;
1301
+ // (void)__rhs;
1302
+ // static_assert(false, "Can not move from a pair<const T, U>");
1303
+ // TODO: how do I flag this code to NOT run at compile time?
1304
+ // Using static_assert means this can't compile _at all_, regardless of whether this code is actually going to execute at compile time or not
1305
+
1306
+ }
1301
1307
1302
1308
1303
1309
0 commit comments