@@ -32,29 +32,19 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __for_each(_InputIterat
32
32
__f (*__first);
33
33
}
34
34
35
- // __segment_processor handles the per-segment processing by applying the function object __func_ to each
36
- // element within the segment.
37
- template <class _Func >
38
- struct __segment_processor {
39
- _Func& __func_;
40
-
41
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __segment_processor (_Func& __f) : __func_(__f) {}
42
-
43
- template <class _SegmentedIterator >
44
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
45
- operator ()(typename __segmented_iterator_traits<_SegmentedIterator>::__local_iterator __lfirst,
46
- typename __segmented_iterator_traits<_SegmentedIterator>::__local_iterator __llast) {
47
- std::__for_each (__lfirst, __llast, __func_);
48
- }
49
- };
50
-
35
+ #ifndef _LIBCPP_CXX03_LANG
51
36
template <class _SegmentedIterator ,
52
37
class _Function ,
53
38
__enable_if_t <__is_segmented_iterator<_SegmentedIterator>::value, int > = 0 >
54
39
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
55
40
__for_each (_SegmentedIterator __first, _SegmentedIterator __last, _Function& __func) {
56
- std::__for_each_segment (__first, __last, std::__segment_processor<_Function>(__func));
41
+ using _Traits = __segmented_iterator_traits<_SegmentedIterator>;
42
+ std::__for_each_segment (
43
+ __first, __last, [&](typename _Traits::__local_iterator __lfirst, typename _Traits::__local_iterator __llast) {
44
+ std::__for_each (__lfirst, __llast, __func);
45
+ });
57
46
}
47
+ #endif
58
48
59
49
template <class _InputIterator , class _Function >
60
50
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Function
0 commit comments