[libcxx-commits] [libcxx] [libc++] Optimize ranges::{for_each, for_each_n} for segmented iterators (PR #132896)

Peng Liu via libcxx-commits libcxx-commits at lists.llvm.org
Thu Apr 3 13:44:21 PDT 2025


================
@@ -19,21 +26,65 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if _LIBCPP_STD_VER >= 17
-
-template <class _InputIterator, class _Size, class _Function>
+template <class _InputIterator,
+          class _Size,
+          class _Function,
+          class _Proj,
+          __enable_if_t<!__has_random_access_iterator_category<_InputIterator>::value &&
+                            (!__is_segmented_iterator<_InputIterator>::value
+                             //   || !__has_random_access_iterator_category<
+                             //      typename __segmented_iterator_traits<_InputIterator>::__local_iterator>::value
+                             ), // TODO: __segmented_iterator_traits<_InputIterator> results in template instantiation
+                                // during SFINAE, which is a hard error to be fixed. Once fixed, we should uncomment.
+                        int> = 0>
----------------
winner245 wrote:

When using `__segmented_iterator_traits<_Iterator>` in SFINEA, I encountered a hard error caused by template instantiation of `__segmented_iterator_traits<_Iterator>` for unsupported `_Iterator` types.  This appears to be a different issue associated with `__segmented_iterator_traits` that requires resolution. To address this, I have submitted PR #134304 as a separate fix.

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


More information about the libcxx-commits mailing list