Debian Codegraph @

3rd_party/range-v3/range/v3/algorithm/starts_with.hpp

raw
1 // Range v3 library
2 //
3 // Copyright 2019 Christopher Di Bella
4 //
5 // Use, modification and distribution is subject to the
6 // Boost Software License, Version 1.0. (See accompanying
7 // file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9 //
10 // Project home: https://github.com/ericniebler/range-v3
11 #ifndef RANGES_V3_ALGORITHM_STARTS_WITH_HPP
12 #define RANGES_V3_ALGORITHM_STARTS_WITH_HPP
13
14 #include <utility>
15
16 #include <range/v3/range_fwd.hpp>
17
18 #include <range/v3/algorithm/equal.hpp>
19 #include <range/v3/algorithm/mismatch.hpp>
20 #include <range/v3/functional/comparisons.hpp>
21 #include <range/v3/functional/identity.hpp>
22 #include <range/v3/iterator/concepts.hpp>
23 #include <range/v3/iterator/operations.hpp>
24 #include <range/v3/range/access.hpp>
25 #include <range/v3/range/concepts.hpp>
26 #include <range/v3/range/traits.hpp>
27 #include <range/v3/utility/static_const.hpp>
28
29 #include <range/v3/detail/prologue.hpp>
30
31 namespace ranges
32 {
33 /// \addtogroup group-algorithms
34 /// @{
35
36 // template<typename I1, typename I2>
37 // struct starts_with_result : detail::in1_in2_result<I1, I2>
38 // {
39 // bool result;
40 // };
41
42 RANGES_FUNC_BEGIN(starts_with)
43
44 /// \brief function template \c starts_with
45 template(typename I1,
46 typename S1,
47 typename I2,
48 typename S2,
49 typename Comp = equal_to,
50 typename Proj1 = identity,
51 typename Proj2 = identity)(
52 requires input_iterator<I1> AND sentinel_for<S1, I1> AND
53 input_iterator<I2> AND sentinel_for<S2, I2> AND
54 indirectly_comparable<I1, I2, Comp, Proj1, Proj2>)
55 constexpr bool RANGES_FUNC(starts_with)(I1 first1,
56 S1 last1,
57 I2 first2,
58 S2 last2,
59 Comp comp = {},
60 Proj1 proj1 = {},
61 Proj2 proj2 = {}) //
62 {
63 return mismatch(std::move(first1),
64 std::move(last1),
65 std::move(first2),
66 last2,
67 std::move(comp),
68 std::move(proj1),
69 std::move(proj2))
70 .in2 == last2;
71 }
72
73 /// \overload
74 template(typename R1,
75 typename R2,
76 typename Comp = equal_to,
77 typename Proj1 = identity,
78 typename Proj2 = identity)(
79 requires input_range<R1> AND input_range<R2> AND
80 indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Comp, Proj1, Proj2>)
81 constexpr bool RANGES_FUNC(starts_with)(
82 R1 && r1, R2 && r2, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) //
83 {
84 return (*this)( //
85 begin(r1),
86 end(r1),
87 begin(r2),
88 end(r2),
89 std::move(comp),
90 std::move(proj1),
91 std::move(proj2));
92 }
93
94 RANGES_FUNC_END(starts_with)
95 /// @}
96 } // namespace ranges
97
98 #include <range/v3/detail/epilogue.hpp>
99
100 #endif // RANGES_V3_ALGORITHM_STARTS_WITH_HPP