File indexing completed on 2025-12-16 10:27:55
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef RANGES_V3_ALGORITHM_STARTS_WITH_HPP
0012 #define RANGES_V3_ALGORITHM_STARTS_WITH_HPP
0013
0014 #include <utility>
0015
0016 #include <range/v3/range_fwd.hpp>
0017
0018 #include <range/v3/algorithm/equal.hpp>
0019 #include <range/v3/algorithm/mismatch.hpp>
0020 #include <range/v3/functional/comparisons.hpp>
0021 #include <range/v3/functional/identity.hpp>
0022 #include <range/v3/iterator/concepts.hpp>
0023 #include <range/v3/iterator/operations.hpp>
0024 #include <range/v3/range/access.hpp>
0025 #include <range/v3/range/concepts.hpp>
0026 #include <range/v3/range/traits.hpp>
0027 #include <range/v3/utility/static_const.hpp>
0028
0029 #include <range/v3/detail/prologue.hpp>
0030
0031 namespace ranges
0032 {
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 RANGES_FUNC_BEGIN(starts_with)
0043
0044
0045 template(typename I1,
0046 typename S1,
0047 typename I2,
0048 typename S2,
0049 typename Comp = equal_to,
0050 typename Proj1 = identity,
0051 typename Proj2 = identity)(
0052 requires input_iterator<I1> AND sentinel_for<S1, I1> AND
0053 input_iterator<I2> AND sentinel_for<S2, I2> AND
0054 indirectly_comparable<I1, I2, Comp, Proj1, Proj2>)
0055 constexpr bool RANGES_FUNC(starts_with)(I1 first1,
0056 S1 last1,
0057 I2 first2,
0058 S2 last2,
0059 Comp comp = {},
0060 Proj1 proj1 = {},
0061 Proj2 proj2 = {})
0062 {
0063 return mismatch(std::move(first1),
0064 std::move(last1),
0065 std::move(first2),
0066 last2,
0067 std::move(comp),
0068 std::move(proj1),
0069 std::move(proj2))
0070 .in2 == last2;
0071 }
0072
0073
0074 template(typename R1,
0075 typename R2,
0076 typename Comp = equal_to,
0077 typename Proj1 = identity,
0078 typename Proj2 = identity)(
0079 requires input_range<R1> AND input_range<R2> AND
0080 indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Comp, Proj1, Proj2>)
0081 constexpr bool RANGES_FUNC(starts_with)(
0082 R1 && r1, R2 && r2, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {})
0083 {
0084 return (*this)(
0085 begin(r1),
0086 end(r1),
0087 begin(r2),
0088 end(r2),
0089 std::move(comp),
0090 std::move(proj1),
0091 std::move(proj2));
0092 }
0093
0094 RANGES_FUNC_END(starts_with)
0095
0096 }
0097
0098 #include <range/v3/detail/epilogue.hpp>
0099
0100 #endif