Warning: This file is not a C or C++ file. It does not have highlighting.
| 1 | // -*- C++ -*- |
|---|---|
| 2 | //===----------------------------------------------------------------------===// |
| 3 | // |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | // See https://llvm.org/LICENSE.txt for license information. |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef _LIBCPP___ALGORITHM_FOR_EACH_H |
| 11 | #define _LIBCPP___ALGORITHM_FOR_EACH_H |
| 12 | |
| 13 | #include <__algorithm/for_each_segment.h> |
| 14 | #include <__config> |
| 15 | #include <__iterator/segmented_iterator.h> |
| 16 | #include <__type_traits/enable_if.h> |
| 17 | |
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | # pragma GCC system_header |
| 20 | #endif |
| 21 | |
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | |
| 24 | template <class _InputIterator, class _Sent, class _Func> |
| 25 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __for_each(_InputIterator __first, _Sent __last, _Func& __f) { |
| 26 | for (; __first != __last; ++__first) |
| 27 | __f(*__first); |
| 28 | } |
| 29 | |
| 30 | #ifndef _LIBCPP_CXX03_LANG |
| 31 | template <class _SegmentedIterator, |
| 32 | class _Function, |
| 33 | __enable_if_t<__is_segmented_iterator<_SegmentedIterator>::value, int> = 0> |
| 34 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 35 | __for_each(_SegmentedIterator __first, _SegmentedIterator __last, _Function& __func) { |
| 36 | using __local_iterator_t = typename __segmented_iterator_traits<_SegmentedIterator>::__local_iterator; |
| 37 | std::__for_each_segment(__first, __last, [&](__local_iterator_t __lfirst, __local_iterator_t __llast) { |
| 38 | std::__for_each(__lfirst, __llast, __func); |
| 39 | }); |
| 40 | } |
| 41 | #endif // !_LIBCPP_CXX03_LANG |
| 42 | |
| 43 | template <class _InputIterator, class _Function> |
| 44 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Function |
| 45 | for_each(_InputIterator __first, _InputIterator __last, _Function __f) { |
| 46 | std::__for_each(__first, __last, __f); |
| 47 | return __f; |
| 48 | } |
| 49 | |
| 50 | _LIBCPP_END_NAMESPACE_STD |
| 51 | |
| 52 | #endif // _LIBCPP___ALGORITHM_FOR_EACH_H |
| 53 |
Warning: This file is not a C or C++ file. It does not have highlighting.
