File indexing completed on 2026-05-03 08:13:19
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _LIBCPP___CXX03___ALGORITHM_RANGES_FIND_H
0010 #define _LIBCPP___CXX03___ALGORITHM_RANGES_FIND_H
0011
0012 #include <__cxx03/__algorithm/find.h>
0013 #include <__cxx03/__algorithm/ranges_find_if.h>
0014 #include <__cxx03/__algorithm/unwrap_range.h>
0015 #include <__cxx03/__config>
0016 #include <__cxx03/__functional/identity.h>
0017 #include <__cxx03/__functional/invoke.h>
0018 #include <__cxx03/__functional/ranges_operations.h>
0019 #include <__cxx03/__iterator/concepts.h>
0020 #include <__cxx03/__iterator/projected.h>
0021 #include <__cxx03/__ranges/access.h>
0022 #include <__cxx03/__ranges/concepts.h>
0023 #include <__cxx03/__ranges/dangling.h>
0024 #include <__cxx03/__utility/forward.h>
0025 #include <__cxx03/__utility/move.h>
0026
0027 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0028 # pragma GCC system_header
0029 #endif
0030
0031 _LIBCPP_PUSH_MACROS
0032 #include <__cxx03/__undef_macros>
0033
0034 #if _LIBCPP_STD_VER >= 20
0035
0036 _LIBCPP_BEGIN_NAMESPACE_STD
0037
0038 namespace ranges {
0039 namespace __find {
0040 struct __fn {
0041 template <class _Iter, class _Sent, class _Tp, class _Proj>
0042 _LIBCPP_HIDE_FROM_ABI static constexpr _Iter
0043 __find_unwrap(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) {
0044 if constexpr (forward_iterator<_Iter>) {
0045 auto [__first_un, __last_un] = std::__unwrap_range(__first, std::move(__last));
0046 return std::__rewrap_range<_Sent>(
0047 std::move(__first), std::__find(std::move(__first_un), std::move(__last_un), __value, __proj));
0048 } else {
0049 return std::__find(std::move(__first), std::move(__last), __value, __proj);
0050 }
0051 }
0052
0053 template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, class _Proj = identity>
0054 requires indirect_binary_predicate<ranges::equal_to, projected<_Ip, _Proj>, const _Tp*>
0055 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip
0056 operator()(_Ip __first, _Sp __last, const _Tp& __value, _Proj __proj = {}) const {
0057 return __find_unwrap(std::move(__first), std::move(__last), __value, __proj);
0058 }
0059
0060 template <input_range _Rp, class _Tp, class _Proj = identity>
0061 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Rp>, _Proj>, const _Tp*>
0062 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp>
0063 operator()(_Rp&& __r, const _Tp& __value, _Proj __proj = {}) const {
0064 return __find_unwrap(ranges::begin(__r), ranges::end(__r), __value, __proj);
0065 }
0066 };
0067 }
0068
0069 inline namespace __cpo {
0070 inline constexpr auto find = __find::__fn{};
0071 }
0072 }
0073
0074 _LIBCPP_END_NAMESPACE_STD
0075
0076 #endif
0077
0078 _LIBCPP_POP_MACROS
0079
0080 #endif