[libcxx-commits] [libcxx] [libc++] Fix assignment in insertion into `vector` (PR #116001)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Tue Feb 18 03:01:02 PST 2025


================
@@ -594,6 +598,30 @@ class _LIBCPP_TEMPLATE_VIS vector {
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
   __assign_with_size(_ForwardIterator __first, _Sentinel __last, difference_type __n);
 
+  template <class _Iterator,
+            __enable_if_t<!is_same<decltype(*std::declval<_Iterator&>())&&, value_type&&>::value, int> = 0>
+  _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
+  __insert_assign_n_unchecked(_Iterator __first, difference_type __n, pointer __position) {
+    for (pointer __end_position = __position + __n; __position != __end_position; (void)++__position, ++__first) {
----------------
frederick-vs-ja wrote:

Thanks! Although I believe the effects are exactly same.

It's conventional to `void`-cast the first operand in the standard wording. But in libc++ `void`-casting the second one seems conventional. What an unfortunate style mismatch.

https://github.com/llvm/llvm-project/pull/116001


More information about the libcxx-commits mailing list