File indexing completed on 2026-05-03 08:13:08
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _LIBCPP___ALGORITHM_FOR_EACH_N_H
0011 #define _LIBCPP___ALGORITHM_FOR_EACH_N_H
0012
0013 #include <__config>
0014 #include <__utility/convert_to_integral.h>
0015
0016 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0017 # pragma GCC system_header
0018 #endif
0019
0020 _LIBCPP_BEGIN_NAMESPACE_STD
0021
0022 #if _LIBCPP_STD_VER >= 17
0023
0024 template <class _InputIterator, class _Size, class _Function>
0025 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
0026 for_each_n(_InputIterator __first, _Size __orig_n, _Function __f) {
0027 typedef decltype(std::__convert_to_integral(__orig_n)) _IntegralSize;
0028 _IntegralSize __n = __orig_n;
0029 while (__n > 0) {
0030 __f(*__first);
0031 ++__first;
0032 --__n;
0033 }
0034 return __first;
0035 }
0036
0037 #endif
0038
0039 _LIBCPP_END_NAMESPACE_STD
0040
0041 #endif