[libcxx-commits] [libcxx] [libc++] Use views::reverse to implement ranges::reverse_copy (PR #177123)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jan 30 09:29:22 PST 2026


================
@@ -49,7 +50,7 @@ struct __reverse_copy {
     requires indirectly_copyable<iterator_t<_Range>, _OutIter>
   _LIBCPP_HIDE_FROM_ABI constexpr reverse_copy_result<borrowed_iterator_t<_Range>, _OutIter>
   operator()(_Range&& __range, _OutIter __result) const {
-    auto __ret = ranges::copy(std::__reverse_range(__range), std::move(__result));
----------------
philnik777 wrote:

The patch as-is causes `<algorithm>` to be 20% larger, while a lot of other headers get smaller. The actual compile time difference is significantly smaller (~5%). Overall I don't think the extra function is worth the reduced dependency just inside `<algorithm>`.

Looking from it the other way: I wouldn't propose adding `__reverse_range` if it were implemented with `views::reverse` right now.

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


More information about the libcxx-commits mailing list