Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:19

0001 //===----------------------------------------------------------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef _LIBCPP___CXX03___ALGORITHM_RANGES_FIND_FIRST_OF_H
0010 #define _LIBCPP___CXX03___ALGORITHM_RANGES_FIND_FIRST_OF_H
0011 
0012 #include <__cxx03/__config>
0013 #include <__cxx03/__functional/identity.h>
0014 #include <__cxx03/__functional/invoke.h>
0015 #include <__cxx03/__functional/ranges_operations.h>
0016 #include <__cxx03/__iterator/concepts.h>
0017 #include <__cxx03/__iterator/indirectly_comparable.h>
0018 #include <__cxx03/__ranges/access.h>
0019 #include <__cxx03/__ranges/concepts.h>
0020 #include <__cxx03/__ranges/dangling.h>
0021 #include <__cxx03/__utility/move.h>
0022 
0023 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0024 #  pragma GCC system_header
0025 #endif
0026 
0027 _LIBCPP_PUSH_MACROS
0028 #include <__cxx03/__undef_macros>
0029 
0030 #if _LIBCPP_STD_VER >= 20
0031 
0032 _LIBCPP_BEGIN_NAMESPACE_STD
0033 
0034 namespace ranges {
0035 namespace __find_first_of {
0036 struct __fn {
0037   template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
0038   _LIBCPP_HIDE_FROM_ABI constexpr static _Iter1 __find_first_of_impl(
0039       _Iter1 __first1,
0040       _Sent1 __last1,
0041       _Iter2 __first2,
0042       _Sent2 __last2,
0043       _Pred& __pred,
0044       _Proj1& __proj1,
0045       _Proj2& __proj2) {
0046     for (; __first1 != __last1; ++__first1) {
0047       for (auto __j = __first2; __j != __last2; ++__j) {
0048         if (std::invoke(__pred, std::invoke(__proj1, *__first1), std::invoke(__proj2, *__j)))
0049           return __first1;
0050       }
0051     }
0052     return __first1;
0053   }
0054 
0055   template <input_iterator _Iter1,
0056             sentinel_for<_Iter1> _Sent1,
0057             forward_iterator _Iter2,
0058             sentinel_for<_Iter2> _Sent2,
0059             class _Pred  = ranges::equal_to,
0060             class _Proj1 = identity,
0061             class _Proj2 = identity>
0062     requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
0063   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter1 operator()(
0064       _Iter1 __first1,
0065       _Sent1 __last1,
0066       _Iter2 __first2,
0067       _Sent2 __last2,
0068       _Pred __pred   = {},
0069       _Proj1 __proj1 = {},
0070       _Proj2 __proj2 = {}) const {
0071     return __find_first_of_impl(
0072         std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), __pred, __proj1, __proj2);
0073   }
0074 
0075   template <input_range _Range1,
0076             forward_range _Range2,
0077             class _Pred  = ranges::equal_to,
0078             class _Proj1 = identity,
0079             class _Proj2 = identity>
0080     requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
0081   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range1> operator()(
0082       _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
0083     return __find_first_of_impl(
0084         ranges::begin(__range1),
0085         ranges::end(__range1),
0086         ranges::begin(__range2),
0087         ranges::end(__range2),
0088         __pred,
0089         __proj1,
0090         __proj2);
0091   }
0092 };
0093 } // namespace __find_first_of
0094 
0095 inline namespace __cpo {
0096 inline constexpr auto find_first_of = __find_first_of::__fn{};
0097 } // namespace __cpo
0098 } // namespace ranges
0099 
0100 _LIBCPP_END_NAMESPACE_STD
0101 
0102 #endif // _LIBCPP_STD_VER >= 20
0103 
0104 _LIBCPP_POP_MACROS
0105 
0106 #endif // _LIBCPP___CXX03___ALGORITHM_RANGES_FIND_FIRST_OF_H