comparison libcxx/include/__algorithm/ranges_adjacent_find.h @ 252:1f2b6ac9f198 llvm-original

LLVM16-1
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 18 Aug 2023 09:04:13 +0900
parents c4bab56944e8
children
comparison
equal deleted inserted replaced
237:c80f45b162ad 252:1f2b6ac9f198
22 22
23 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 23 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24 # pragma GCC system_header 24 # pragma GCC system_header
25 #endif 25 #endif
26 26
27 #if _LIBCPP_STD_VER > 17 27 #if _LIBCPP_STD_VER >= 20
28 28
29 _LIBCPP_BEGIN_NAMESPACE_STD 29 _LIBCPP_BEGIN_NAMESPACE_STD
30 30
31 namespace ranges { 31 namespace ranges {
32 namespace __adjacent_find { 32 namespace __adjacent_find {
33 struct __fn { 33 struct __fn {
34
35 template <class _Iter, class _Sent, class _Proj, class _Pred> 34 template <class _Iter, class _Sent, class _Proj, class _Pred>
36 _LIBCPP_HIDE_FROM_ABI constexpr static 35 _LIBCPP_HIDE_FROM_ABI constexpr static _Iter
37 _Iter __adjacent_find_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { 36 __adjacent_find_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
38 if (__first == __last) 37 if (__first == __last)
39 return __first; 38 return __first;
40 39
41 auto __i = __first; 40 auto __i = __first;
42 while (++__i != __last) { 41 while (++__i != __last) {
45 __first = __i; 44 __first = __i;
46 } 45 }
47 return __i; 46 return __i;
48 } 47 }
49 48
50 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, 49 template <forward_iterator _Iter,
51 class _Proj = identity, 50 sentinel_for<_Iter> _Sent,
51 class _Proj = identity,
52 indirect_binary_predicate<projected<_Iter, _Proj>, projected<_Iter, _Proj>> _Pred = ranges::equal_to> 52 indirect_binary_predicate<projected<_Iter, _Proj>, projected<_Iter, _Proj>> _Pred = ranges::equal_to>
53 _LIBCPP_HIDE_FROM_ABI constexpr 53 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Iter
54 _Iter operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const { 54 operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {
55 return __adjacent_find_impl(std::move(__first), std::move(__last), __pred, __proj); 55 return __adjacent_find_impl(std::move(__first), std::move(__last), __pred, __proj);
56 } 56 }
57 57
58 template <forward_range _Range, 58 template <forward_range _Range,
59 class _Proj = identity, 59 class _Proj = identity,
60 indirect_binary_predicate<projected<iterator_t<_Range>, _Proj>, 60 indirect_binary_predicate<projected<iterator_t<_Range>, _Proj>, projected<iterator_t<_Range>, _Proj>>
61 projected<iterator_t<_Range>, _Proj>> _Pred = ranges::equal_to> 61 _Pred = ranges::equal_to>
62 _LIBCPP_HIDE_FROM_ABI constexpr 62 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range>
63 borrowed_iterator_t<_Range> operator()(_Range&& __range, _Pred __pred = {}, _Proj __proj = {}) const { 63 operator()(_Range&& __range, _Pred __pred = {}, _Proj __proj = {}) const {
64 return __adjacent_find_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); 64 return __adjacent_find_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
65 } 65 }
66 }; 66 };
67 } // namespace __adjacent_find 67 } // namespace __adjacent_find
68 68
69 inline namespace __cpo { 69 inline namespace __cpo {
70 inline constexpr auto adjacent_find = __adjacent_find::__fn{}; 70 inline constexpr auto adjacent_find = __adjacent_find::__fn{};
71 } // namespace __cpo 71 } // namespace __cpo
72 } // namespace ranges 72 } // namespace ranges
73 73
74 _LIBCPP_END_NAMESPACE_STD 74 _LIBCPP_END_NAMESPACE_STD
75 75
76 #endif // _LIBCPP_STD_VER > 17 76 #endif // _LIBCPP_STD_VER >= 20
77 77
78 #endif // _LIBCPP___ALGORITHM_RANGES_ADJACENT_FIND_H 78 #endif // _LIBCPP___ALGORITHM_RANGES_ADJACENT_FIND_H