Skip to content

Commit fa77a07

Browse files
<__type_traits/is_constant_evaluated.h>
1 parent 2b8603c commit fa77a07

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

libcxx/include/__tree

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <__type_traits/copy_cvref.h>
3030
#include <__type_traits/enable_if.h>
3131
#include <__type_traits/invoke.h>
32+
#include <__type_traits/is_constant_evaluated.h>
3233
#include <__type_traits/is_const.h>
3334
#include <__type_traits/is_constructible.h>
3435
#include <__type_traits/is_nothrow_assignable.h>
@@ -1375,17 +1376,19 @@ private:
13751376
using __key_type = typename _NodeTypes::key_type;
13761377

13771378
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;
13811384
// __lhs = pair<const int, double>
13821385
// TODO: use a better name
13831386
using foo_type = __get_node_value_type_t<value_type>;
13841387
// const_cast is not allowed at constexpr time.
13851388
// 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);
13891392
} else {
13901393
// This is technically UB, since the object was constructed as `const`.
13911394
// Clang doesn't optimize on this currently though.

0 commit comments

Comments
 (0)