1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef _LIBCPP___ALGORITHM_RANGES_FIND_END_H
10 #define _LIBCPP___ALGORITHM_RANGES_FIND_END_H
12 #include <__cxx03/__algorithm/find_end.h>
13 #include <__cxx03/__algorithm/iterator_operations.h>
14 #include <__cxx03/__algorithm/ranges_iterator_concept.h>
15 #include <__cxx03/__config>
16 #include <__cxx03/__functional/identity.h>
17 #include <__cxx03/__functional/ranges_operations.h>
18 #include <__cxx03/__iterator/concepts.h>
19 #include <__cxx03/__iterator/indirectly_comparable.h>
20 #include <__cxx03/__iterator/iterator_traits.h>
21 #include <__cxx03/__ranges/access.h>
22 #include <__cxx03/__ranges/concepts.h>
23 #include <__cxx03/__ranges/subrange.h>
24 #include <__cxx03/__utility/pair.h>
26 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27 # pragma GCC system_header
31 #include <__cxx03/__undef_macros>
33 #if _LIBCPP_STD_VER >= 20
35 _LIBCPP_BEGIN_NAMESPACE_STD
38 namespace __find_end
{
40 template <forward_iterator _Iter1
,
41 sentinel_for
<_Iter1
> _Sent1
,
42 forward_iterator _Iter2
,
43 sentinel_for
<_Iter2
> _Sent2
,
44 class _Pred
= ranges::equal_to
,
45 class _Proj1
= identity
,
46 class _Proj2
= identity
>
47 requires indirectly_comparable
<_Iter1
, _Iter2
, _Pred
, _Proj1
, _Proj2
>
48 [[nodiscard
]] _LIBCPP_HIDE_FROM_ABI
constexpr subrange
<_Iter1
> operator()(
55 _Proj2 __proj2
= {}) const {
56 auto __ret
= std::__find_end_impl
<_RangeAlgPolicy
>(
64 __iterator_concept
<_Iter1
>(),
65 __iterator_concept
<_Iter2
>());
66 return {__ret
.first
, __ret
.second
};
69 template <forward_range _Range1
,
70 forward_range _Range2
,
71 class _Pred
= ranges::equal_to
,
72 class _Proj1
= identity
,
73 class _Proj2
= identity
>
74 requires indirectly_comparable
<iterator_t
<_Range1
>, iterator_t
<_Range2
>, _Pred
, _Proj1
, _Proj2
>
75 [[nodiscard
]] _LIBCPP_HIDE_FROM_ABI
constexpr borrowed_subrange_t
<_Range1
> operator()(
76 _Range1
&& __range1
, _Range2
&& __range2
, _Pred __pred
= {}, _Proj1 __proj1
= {}, _Proj2 __proj2
= {}) const {
77 auto __ret
= std::__find_end_impl
<_RangeAlgPolicy
>(
78 ranges::begin(__range1
),
79 ranges::end(__range1
),
80 ranges::begin(__range2
),
81 ranges::end(__range2
),
85 __iterator_concept
<iterator_t
<_Range1
>>(),
86 __iterator_concept
<iterator_t
<_Range2
>>());
87 return {__ret
.first
, __ret
.second
};
90 } // namespace __find_end
92 inline namespace __cpo
{
93 inline constexpr auto find_end
= __find_end::__fn
{};
97 _LIBCPP_END_NAMESPACE_STD
99 #endif // _LIBCPP_STD_VER >= 20
103 #endif // _LIBCPP___ALGORITHM_RANGES_FIND_END_H