|
29 | 29 | #include <__type_traits/copy_cvref.h> |
30 | 30 | #include <__type_traits/enable_if.h> |
31 | 31 | #include <__type_traits/invoke.h> |
| 32 | +#include <__type_traits/is_constant_evaluated.h> |
32 | 33 | #include <__type_traits/is_const.h> |
33 | 34 | #include <__type_traits/is_constructible.h> |
34 | 35 | #include <__type_traits/is_nothrow_assignable.h> |
@@ -1375,17 +1376,19 @@ private: |
1375 | 1376 | using __key_type = typename _NodeTypes::key_type; |
1376 | 1377 |
|
1377 | 1378 | if (std::is_constant_evaluated()) { |
1378 | | - __get_node_value_type_t<value_type> tmp{__rhs.first, __rhs.second}; |
1379 | | - // tmp.first = const_cast<__copy_cvref_t<_From, __key_type>&&>(__rhs.first); |
1380 | | - // tmp.second = std::forward<_From>(__rhs).second; |
| 1379 | + __get_node_value_type_t<value_type> |
| 1380 | + // pair< typename std::remove_const<value_type::first_type>::type, typename value_type::second_type > |
| 1381 | + tmp {__rhs.first, __rhs.second}; |
| 1382 | + tmp.first = const_cast<__copy_cvref_t<_From, __key_type>&&>(__rhs.first); |
| 1383 | + tmp.second = std::forward<_From>(__rhs).second; |
1381 | 1384 | // __lhs = pair<const int, double> |
1382 | 1385 | // TODO: use a better name |
1383 | 1386 | using foo_type = __get_node_value_type_t<value_type>; |
1384 | 1387 | // const_cast is not allowed at constexpr time. |
1385 | 1388 | // we get around this by deleting and creating a new node value |
1386 | | - __lhs.~foo_type(); |
1387 | | - new (std::addressof(__lhs))(foo_type)(tmp); |
1388 | | - // __lhs = std::move(tmp); |
| 1389 | + // __lhs.~foo_type(); |
| 1390 | + // new (std::addressof(__lhs))(foo_type)(std::move(tmp)); |
| 1391 | + __lhs = std::move(tmp); |
1389 | 1392 | } else { |
1390 | 1393 | // This is technically UB, since the object was constructed as `const`. |
1391 | 1394 | // Clang doesn't optimize on this currently though. |
|
0 commit comments