[libcxx-commits] [libcxx] [libc++] Optimize ranges::move{, _backward} for vector<bool>::iterator (PR #121109)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Feb 5 09:04:43 PST 2025


================
@@ -98,6 +100,14 @@ struct __move_impl {
     }
   }
 
+  template <class _Cp, bool _IsConst>
+  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__bit_iterator<_Cp, _IsConst>, __bit_iterator<_Cp, false> >
+  operator()(__bit_iterator<_Cp, _IsConst> __first,
+             __bit_iterator<_Cp, _IsConst> __last,
+             __bit_iterator<_Cp, false> __result) {
+    return std::__copy(__first, __last, __result);
----------------
ldionne wrote:

```suggestion
    return std::copy(__first, __last, __result); // copy is optimized for __bit_iterator
```

This reduces dependencies on internal APIs between files a little bit, which is nice. The same applies to `copy_backward`.

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


More information about the libcxx-commits mailing list