Horizon
starts_with.hpp
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 
27 #include <range/v3/utility/static_const.hpp>
28 
29 #include <range/v3/detail/prologue.hpp>
30 
31 namespace ranges
32 {
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 
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 
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
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)
96 } // namespace ranges
97 
98 #include <range/v3/detail/epilogue.hpp>
99 
100 #endif // RANGES_V3_ALGORITHM_STARTS_WITH_HPP
template(typename R1, typename R2, typename Comp=equal_to, typename Proj1=identity, typename Proj2=identity)(requires input_range< R1 > AND input_range< R2 > AND indirectly_comparable< iterator_t< R1 >
This is an overloaded member function, provided for convenience. It differs from the above function o...
CPP_concept sentinel_for
\concept sentinel_for
Definition: concepts.hpp:306
CPP_concept indirectly_comparable
\concept indirectly_comparable
Definition: concepts.hpp:832
CPP_concept input_iterator
\concept input_iterator
Definition: concepts.hpp:362
decltype(begin(declval(Rng &))) iterator_t
Definition: access.hpp:698
bool_< T::type::value==U::type::value > equal_to
A Boolean integral constant wrapper around the result of comparing T::type::value and U::type::value ...
Definition: meta.hpp:237
Definition: comparisons.hpp:28
Definition: identity.hpp:25