1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef _LIBCPP___ALGORITHM_RANGES_FIND_END_H 10 #define _LIBCPP___ALGORITHM_RANGES_FIND_END_H 11 12 #include <__algorithm/find_end.h> 13 #include <__algorithm/iterator_operations.h> 14 #include <__algorithm/ranges_iterator_concept.h> 15 #include <__config> 16 #include <__functional/identity.h> 17 #include <__functional/ranges_operations.h> 18 #include <__iterator/concepts.h> 19 #include <__iterator/indirectly_comparable.h> 20 #include <__iterator/iterator_traits.h> 21 #include <__ranges/access.h> 22 #include <__ranges/concepts.h> 23 #include <__ranges/subrange.h> 24 #include <__utility/pair.h> 25 26 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 27 # pragma GCC system_header 28 #endif 29 30 #if _LIBCPP_STD_VER > 17 31 32 _LIBCPP_BEGIN_NAMESPACE_STD 33 34 namespace ranges { 35 namespace __find_end { 36 struct __fn { 37 template <forward_iterator _Iter1, sentinel_for<_Iter1> _Sent1, 38 forward_iterator _Iter2, sentinel_for<_Iter2> _Sent2, 39 class _Pred = ranges::equal_to, 40 class _Proj1 = identity, 41 class _Proj2 = identity> 42 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> 43 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr 44 subrange<_Iter1> operator()(_Iter1 __first1, _Sent1 __last1, 45 _Iter2 __first2, _Sent2 __last2, 46 _Pred __pred = {}, 47 _Proj1 __proj1 = {}, 48 _Proj2 __proj2 = {}) const { 49 auto __ret = std::__find_end_impl<_RangeAlgPolicy>( 50 __first1, 51 __last1, 52 __first2, 53 __last2, 54 __pred, 55 __proj1, 56 __proj2, 57 __iterator_concept<_Iter1>(), 58 __iterator_concept<_Iter2>()); 59 return {__ret.first, __ret.second}; 60 } 61 62 template <forward_range _Range1, 63 forward_range _Range2, 64 class _Pred = ranges::equal_to, 65 class _Proj1 = identity, 66 class _Proj2 = identity> 67 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> 68 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr 69 borrowed_subrange_t<_Range1> operator()(_Range1&& __range1, 70 _Range2&& __range2, 71 _Pred __pred = {}, 72 _Proj1 __proj1 = {}, 73 _Proj2 __proj2 = {}) const { 74 auto __ret = std::__find_end_impl<_RangeAlgPolicy>( 75 ranges::begin(__range1), 76 ranges::end(__range1), 77 ranges::begin(__range2), 78 ranges::end(__range2), 79 __pred, 80 __proj1, 81 __proj2, 82 __iterator_concept<iterator_t<_Range1>>(), 83 __iterator_concept<iterator_t<_Range2>>()); 84 return {__ret.first, __ret.second}; 85 } 86 }; 87 } // namespace __find_end 88 89 inline namespace __cpo { 90 inline constexpr auto find_end = __find_end::__fn{}; 91 } // namespace __cpo 92 } // namespace ranges 93 94 _LIBCPP_END_NAMESPACE_STD 95 96 #endif // _LIBCPP_STD_VER > 17 97 98 #endif // _LIBCPP___ALGORITHM_RANGES_FIND_END_H 99