[libcxx-commits] [libcxx] [libcxx] Optimize std::generate for segmented iterators (PR #163006)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Oct 15 00:31:53 PDT 2025
================
@@ -20,8 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _ForwardIterator, class _Generator>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen) {
- for (; __first != __last; ++__first)
- *__first = __gen();
+ std::for_each(__first, __last, [&](auto& __element) { __element = __gen(); });
----------------
philnik777 wrote:
Let's `std::forward` here.
https://github.com/llvm/llvm-project/pull/163006
More information about the libcxx-commits
mailing list