[libcxx-commits] [libcxx] [libc++] Avoid type-punning between __value_type and pair (PR #134819)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Thu May 8 00:18:56 PDT 2025
================
@@ -1276,6 +1278,19 @@ private:
}
_LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__tree&, false_type) _NOEXCEPT {}
+ template <class _From, __enable_if_t<__is_pair_v<__remove_cvref_t<_From> >, int> = 0>
+ _LIBCPP_HIDE_FROM_ABI static void __assign_value(__get_node_value_type_t<value_type>& __lhs, _From&& __rhs) {
+ using __key_type = typename _NodeTypes::key_type;
+
+ const_cast<__key_type&>(__lhs.first) = const_cast<__copy_cvref_t<_From, __key_type>&&>(__rhs.first);
----------------
philnik777 wrote:
We're overwriting the contents of a node here. The whole point of this is to change what the key is.
https://github.com/llvm/llvm-project/pull/134819
More information about the libcxx-commits
mailing list