Skip to content

Commit 4cb5709

Browse files
Use __libcpp_is_constant_evaluated, still at 7 failures
1 parent 62f137a commit 4cb5709

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

libcxx/include/__tree

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,18 +1165,18 @@ public:
11651165
__insert_unique_from_orphaned_node(const_iterator __p, __get_node_value_type_t<_Tp>&& __value) {
11661166
using __key_type = typename _NodeTypes::key_type;
11671167
// fails here for move_alloc.pass.cpp
1168-
// if(std::is_constant_evaluated()) {
1169-
// using __node_value_type = __get_node_value_type_t<_Tp>;
1170-
// // __node_value_type tmp {__value.first, __value.second};
1171-
// // __value.~__node_value_type();
1172-
// // new (std::addressof(__value))(__node_value_type)(tmp);
1173-
// // __emplace_hint_unique(__p, tmp);
1174-
// __key_type kk;
1175-
// new (std::addressof(kk))(__key_type)(__value.first);
1176-
// __emplace_hint_unique(__p, std::move(kk), std::move(__value.second));
1177-
// } else {
1168+
if(__libcpp_is_constant_evaluated()) {
1169+
1170+
// __node_allocator& __na = __value.__node_alloc();
1171+
// __node_traits::destroy(__na, std::addressof(__lhs));
1172+
// __node_traits::construct(__na, std::addressof(__lhs), std::move(__tmp));
1173+
__key_type __kk;
1174+
new (std::addressof(__kk))(__key_type)(__value.first);
1175+
// __node_traits::construct(__na, std::addressof(__kk), std::move(__value.first));
1176+
__emplace_hint_unique(__p, std::move(__kk), std::move(__value.second));
1177+
} else {
11781178
__emplace_hint_unique(__p, const_cast<__key_type&&>(__value.first), std::move(__value.second));
1179-
// }
1179+
}
11801180
}
11811181

11821182
template <class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type<_ValueT>::value, int> = 0>
@@ -1374,19 +1374,17 @@ private:
13741374
__assign_value(__get_node_value_type_t<value_type>& __lhs, _From&& __rhs) {
13751375
using __key_type = typename _NodeTypes::key_type;
13761376

1377-
if (std::is_constant_evaluated()) {
1378-
__get_node_value_type_t<value_type>
1379-
// pair< typename std::remove_const<value_type::first_type>::type, typename value_type::second_type >
1380-
tmp {__rhs.first, __rhs.second};
1381-
tmp.first = const_cast<__copy_cvref_t<_From, __key_type>&&>(__rhs.first);
1382-
tmp.second = std::forward<_From>(__rhs).second;
1383-
// __lhs = pair<const int, double>
1384-
using __node_value_type = __get_node_value_type_t<value_type>;
1377+
if (__libcpp_is_constant_evaluated()) {
1378+
__get_node_value_type_t<value_type> __tmp {__rhs.first, __rhs.second};
13851379
// const_cast is not allowed at constexpr time.
13861380
// we get around this by deleting and creating a new node value
1387-
// __lhs.~__node_value_type();
1388-
// new (std::addressof(__lhs))(__node_value_type)(std::move(tmp));
1389-
__lhs = std::move(tmp);
1381+
__lhs.~__node_value_type();
1382+
// todo: use __node_traits::construct
1383+
// __node_allocator& __na = __lhs.__node_alloc();
1384+
// __node_allocator& __na = __rhs.__node_alloc();
1385+
// __node_traits::destroy(__na, std::addressof(__lhs));
1386+
// __node_traits::construct(__na, std::addressof(__lhs), std::move(__tmp));
1387+
new (std::addressof(__lhs))(__node_value_type)(std::move(__tmp));
13901388
} else {
13911389
// This is technically UB, since the object was constructed as `const`.
13921390
// Clang doesn't optimize on this currently though.

0 commit comments

Comments
 (0)