@@ -1079,10 +1079,10 @@ public:
10791079#if _LIBCPP_STD_VER >= 26
10801080 if (std::is_constant_evaluated () && std::is_copy_constructible_v<decltype (__value.first )>) {
10811081 // We create a sfinae wrapper method here, because if the __emplace_hint_unique method gets template instantiated
1082- // within __insert_unique_from_orphaned_node, the code will fail to compile where the value is not
1083- // copy_constructible for runtime execution as well ; unless we use `if constexpr`. Given the copy-constructible
1082+ // within __insert_unique_from_orphaned_node, the code will fail to compile when the value is not
1083+ // copy_constructible (even for runtime execution) ; unless we use `if constexpr`. Given the copy-constructible
10841084 // code path will be a performance regression, we want to restrict it to only execute during constant evaluation
1085- // , we need to delay the template instantiation
1085+ // , hence, we need to delay the template instantiation.
10861086 __emplace_hint_unique__sfinae (
10871087 integral_constant< bool , std::is_copy_constructible_v<decltype (__value.first )> >(),
10881088 __p,
@@ -1434,7 +1434,7 @@ private:
14341434 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
14351435 __assign_value__sfinae (false_type, __get_node_value_type_t <value_type>&, _From&&) {
14361436 // This method body should never be run. It only exists to allow for compilation. See note in __assign_value for
1437- // more information
1437+ // more information.
14381438 }
14391439
14401440 template <class _From , class _ValueT = _Tp, __enable_if_t <__is_tree_value_type_v<_ValueT>, int > = 0 >
@@ -1445,22 +1445,23 @@ private:
14451445#if _LIBCPP_STD_VER >= 26
14461446
14471447 if (std::is_constant_evaluated () && std::is_copy_constructible_v<decltype (__rhs.first )>) {
1448- // we use copy, and not "move" as the constraint
1449- // because we can NOT move from `const key_type`, which is how `value_type` is defined
1450- // atleast for map
1451- // typedef pair<const key_type, mapped_type> value_type;
1452- // so we must copy it
1453-
1454- // const_cast is not allowed at constexpr time.
1455- // we get around this by deleting __lhs and creating a new node in-place
1456- // to avoid const_cast __lhs.first
1457-
1458- // We create a sfinae wrapper method here, because if the body of the true_type overload for
1459- // __assign_value__sfinae() gets template instantiated within __assign_value, the code will fail to compile where
1460- // the value is not copy_constructible for runtime execution as well; unless we use `if constexpr`. Given the
1461- // copy-constructible code path will be a performance regression, we want to restrict it to only execute during
1462- // constant evaluation
1463- // , we need to delay the template instantiation
1448+ // We use copy, and not "move" as the constraint here because we can NOT move
1449+ // from `const key_type`, which is how `value_type` is defined for `std::map`
1450+ // `typedef pair<const key_type, mapped_type> value_type;`
1451+ // so we must copy it to not perform undefined behavior which
1452+ // is disallowed during constant evaluation.
1453+
1454+ // Furthermore, `const_cast` is not allowed during constant evaluation.
1455+ // We get around this by deleting `__lhs` and creating a new node in-place
1456+ // to avoid the `const_cast` when attempting to assign to `__lhs.first`.
1457+
1458+ // We create a sfinae wrapper method here, because if the body of the `true_type` overload for
1459+ // `__assign_value__sfinae()` gets template instantiated within `__assign_value`,
1460+ // the code will fail to compile when
1461+ // the value is not copy_constructible (even for runtime execution); unless we use `if constexpr`.
1462+ // Given that the copy-constructible code path will be a performance regression,
1463+ // we want to restrict it to only execute during constant evaluation
1464+ // , we need to delay the template instantiation.
14641465
14651466 __assign_value__sfinae (std::integral_constant<bool , std::is_copy_constructible_v<decltype (__rhs.first )>>(),
14661467 std::forward<decltype (__lhs)>(__lhs),
0 commit comments