File indexing completed on 2026-05-03 08:13:17
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _LIBCPP___CXX03___ALGORITHM_FOR_EACH_H
0011 #define _LIBCPP___CXX03___ALGORITHM_FOR_EACH_H
0012
0013 #include <__cxx03/__algorithm/for_each_segment.h>
0014 #include <__cxx03/__config>
0015 #include <__cxx03/__iterator/segmented_iterator.h>
0016 #include <__cxx03/__ranges/movable_box.h>
0017 #include <__cxx03/__type_traits/enable_if.h>
0018 #include <__cxx03/__utility/in_place.h>
0019 #include <__cxx03/__utility/move.h>
0020
0021 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0022 # pragma GCC system_header
0023 #endif
0024
0025 _LIBCPP_PUSH_MACROS
0026 #include <__cxx03/__undef_macros>
0027
0028 _LIBCPP_BEGIN_NAMESPACE_STD
0029
0030 template <class _InputIterator, class _Function>
0031 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Function
0032 for_each(_InputIterator __first, _InputIterator __last, _Function __f) {
0033 for (; __first != __last; ++__first)
0034 __f(*__first);
0035 return __f;
0036 }
0037
0038
0039 #if _LIBCPP_STD_VER >= 23
0040 template <class _SegmentedIterator, class _Function>
0041 requires __is_segmented_iterator<_SegmentedIterator>::value
0042 _LIBCPP_HIDE_FROM_ABI constexpr _Function
0043 for_each(_SegmentedIterator __first, _SegmentedIterator __last, _Function __func) {
0044 ranges::__movable_box<_Function> __wrapped_func(in_place, std::move(__func));
0045 std::__for_each_segment(__first, __last, [&](auto __lfirst, auto __llast) {
0046 __wrapped_func =
0047 ranges::__movable_box<_Function>(in_place, std::for_each(__lfirst, __llast, std::move(*__wrapped_func)));
0048 });
0049 return std::move(*__wrapped_func);
0050 }
0051 #endif
0052
0053 _LIBCPP_END_NAMESPACE_STD
0054
0055 _LIBCPP_POP_MACROS
0056
0057 #endif