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