1313#include < __algorithm/for_each_segment.h>
1414#include < __config>
1515#include < __functional/identity.h>
16- #include < __functional/invoke.h>
1716#include < __iterator/segmented_iterator.h>
1817#include < __type_traits/enable_if.h>
18+ #include < __type_traits/invoke.h>
1919#include < __utility/move.h>
2020
2121#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -27,46 +27,45 @@ _LIBCPP_PUSH_MACROS
2727
2828_LIBCPP_BEGIN_NAMESPACE_STD
2929
30- template <class _InputIterator , class _Sent , class _Function , class _Proj >
30+ template <class _InputIterator , class _Sent , class _Func , class _Proj >
3131_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
32- __for_each (_InputIterator __first, _Sent __last, _Function & __f, _Proj& __proj) {
32+ __for_each (_InputIterator __first, _Sent __last, _Func & __f, _Proj& __proj) {
3333 for (; __first != __last; ++__first)
34- std::invoke (__f, std::invoke (__proj, *__first));
34+ std::__invoke (__f, std::__invoke (__proj, *__first));
3535 return __first;
3636}
3737
38- // __segment_processor handles the per-segment processing by applying the user-provided function to each element
39- // within the segment. It acts as a functor passed to the segmented iterator algorithm __for_each_segment.
40- template <class _SegmentedIterator , class _Function , class _Proj >
38+ // __segment_processor handles the per-segment processing by applying the function object __func_ to the
39+ // projected value of each element within the segment. It serves as a functor utilized by the segmented
40+ // iterator algorithms such as __for_each_segment and __for_each_n_segment.
41+ template <class _SegmentedIterator , class _Func >
4142struct __segment_processor {
4243 using _Traits _LIBCPP_NODEBUG = __segmented_iterator_traits<_SegmentedIterator>;
4344
44- _Function& __func_;
45- _Proj& __proj_;
45+ _Func& __func_;
4646
47- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __segment_processor (_Function& __func, _Proj& __proj)
48- : __func_(__func), __proj_(__proj) {}
47+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __segment_processor (_Func& __f) : __func_(__f) {}
4948
50- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
51- operator ()(typename _Traits::__local_iterator __lfirst, typename _Traits::__local_iterator __llast) {
52- std::__for_each (__lfirst, __llast, __func_, __proj_);
49+ template <class _Proj >
50+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
51+ operator ()(typename _Traits::__local_iterator __lfirst, typename _Traits::__local_iterator __llast, _Proj& __proj) {
52+ std::__for_each (__lfirst, __llast, __func_, __proj);
5353 }
5454};
5555
5656template <class _SegmentedIterator ,
57- class _Function ,
57+ class _Func ,
5858 class _Proj ,
5959 __enable_if_t <__is_segmented_iterator<_SegmentedIterator>::value, int > = 0 >
6060_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _SegmentedIterator
61- __for_each (_SegmentedIterator __first, _SegmentedIterator __last, _Function& __func, _Proj& __proj) {
62- std::__for_each_segment (
63- __first, __last, std::__segment_processor<_SegmentedIterator, _Function, _Proj>(__func, __proj));
61+ __for_each (_SegmentedIterator __first, _SegmentedIterator __last, _Func& __f, _Proj& __proj) {
62+ std::__for_each_segment (__first, __last, std::__segment_processor<_SegmentedIterator, _Func>(__f), __proj);
6463 return __last;
6564}
6665
67- template <class _InputIterator , class _Function >
68- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Function
69- for_each (_InputIterator __first, _InputIterator __last, _Function __f) {
66+ template <class _InputIterator , class _Func >
67+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Func
68+ for_each (_InputIterator __first, _InputIterator __last, _Func __f) {
7069 __identity __proj;
7170 std::__for_each (__first, __last, __f, __proj);
7271 return std::move (__f);
0 commit comments