File indexing completed on 2024-11-15 09:54:38
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef RANGES_V3_ALGORITHM_FIND_FIRST_OF_HPP
0014 #define RANGES_V3_ALGORITHM_FIND_FIRST_OF_HPP
0015
0016 #include <utility>
0017
0018 #include <range/v3/range_fwd.hpp>
0019
0020 #include <range/v3/functional/comparisons.hpp>
0021 #include <range/v3/functional/identity.hpp>
0022 #include <range/v3/functional/invoke.hpp>
0023 #include <range/v3/iterator/concepts.hpp>
0024 #include <range/v3/iterator/traits.hpp>
0025 #include <range/v3/range/access.hpp>
0026 #include <range/v3/range/concepts.hpp>
0027 #include <range/v3/range/dangling.hpp>
0028 #include <range/v3/range/traits.hpp>
0029 #include <range/v3/utility/static_const.hpp>
0030
0031 #include <range/v3/detail/prologue.hpp>
0032
0033 namespace ranges
0034 {
0035
0036
0037 RANGES_FUNC_BEGIN(find_first_of)
0038
0039
0040
0041
0042
0043
0044
0045 template(typename I0,
0046 typename S0,
0047 typename I1,
0048 typename S1,
0049 typename R = equal_to,
0050 typename P0 = identity,
0051 typename P1 = identity)(
0052 requires input_iterator<I0> AND sentinel_for<S0, I0> AND
0053 forward_iterator<I1> AND sentinel_for<S1, I1> AND
0054 indirect_relation<R, projected<I0, P0>, projected<I1, P1>>)
0055 constexpr I0 RANGES_FUNC(find_first_of)(I0 begin0,
0056 S0 end0,
0057 I1 begin1,
0058 S1 end1,
0059 R pred = R{},
0060 P0 proj0 = P0{},
0061 P1 proj1 = P1{})
0062 {
0063 for(; begin0 != end0; ++begin0)
0064 for(auto tmp = begin1; tmp != end1; ++tmp)
0065 if(invoke(pred, invoke(proj0, *begin0), invoke(proj1, *tmp)))
0066 return begin0;
0067 return begin0;
0068 }
0069
0070
0071 template(typename Rng0,
0072 typename Rng1,
0073 typename R = equal_to,
0074 typename P0 = identity,
0075 typename P1 = identity)(
0076 requires input_range<Rng0> AND forward_range<Rng1> AND
0077 indirect_relation<R,
0078 projected<iterator_t<Rng0>, P0>,
0079 projected<iterator_t<Rng1>, P1>>)
0080 constexpr borrowed_iterator_t<Rng0> RANGES_FUNC(find_first_of)(
0081 Rng0 && rng0, Rng1 && rng1, R pred = R{}, P0 proj0 = P0{}, P1 proj1 = P1{})
0082 {
0083 return (*this)(begin(rng0),
0084 end(rng0),
0085 begin(rng1),
0086 end(rng1),
0087 std::move(pred),
0088 std::move(proj0),
0089 std::move(proj1));
0090 }
0091
0092 RANGES_FUNC_END(find_first_of)
0093
0094 namespace cpp20
0095 {
0096 using ranges::find_first_of;
0097 }
0098
0099 }
0100
0101 #include <range/v3/detail/epilogue.hpp>
0102
0103 #endif