Horizon
Loading...
Searching...
No Matches
lexicographical_compare.hpp
Go to the documentation of this file.
1
2// Range v3 library
3//
4// Copyright Eric Niebler 2013-present
5//
6// Use, modification and distribution is subject to the
7// Boost Software License, Version 1.0. (See accompanying
8// file LICENSE_1_0.txt or copy at
9// http://www.boost.org/LICENSE_1_0.txt)
10//
11// Project home: https://github.com/ericniebler/range-v3
12//
13#ifndef RANGES_V3_ALGORITHM_LEXICOGRAPHICAL_COMPARE_HPP
14#define RANGES_V3_ALGORITHM_LEXICOGRAPHICAL_COMPARE_HPP
15
17
26#include <range/v3/utility/static_const.hpp>
27
28#include <range/v3/detail/prologue.hpp>
29
30namespace ranges
31{
34 RANGES_FUNC_BEGIN(lexicographical_compare)
35
36
37 template(typename I0,
38 typename S0,
39 typename I1,
40 typename S1,
41 typename C = less,
42 typename P0 = identity,
43 typename P1 = identity)(
44 requires input_iterator<I0> AND sentinel_for<S0, I0> AND
45 input_iterator<I1> AND sentinel_for<S1, I1> AND
46 indirect_strict_weak_order<C, projected<I0, P0>, projected<I1, P1>>)
47 constexpr bool RANGES_FUNC(lexicographical_compare)(I0 begin0,
48 S0 end0,
49 I1 begin1,
50 S1 end1,
51 C pred = C{},
52 P0 proj0 = P0{},
53 P1 proj1 = P1{})
54 {
55 for(; begin1 != end1; ++begin0, ++begin1)
56 {
57 if(begin0 == end0 ||
58 invoke(pred, invoke(proj0, *begin0), invoke(proj1, *begin1)))
59 return true;
60 if(invoke(pred, invoke(proj1, *begin1), invoke(proj0, *begin0)))
61 return false;
62 }
63 return false;
64 }
65
67 template(typename Rng0,
68 typename Rng1,
69 typename C = less,
70 typename P0 = identity,
71 typename P1 = identity)(
74 projected<iterator_t<Rng0>, P0>,
75 projected<iterator_t<Rng1>, P1>>)
76 constexpr bool RANGES_FUNC(lexicographical_compare)(Rng0 && rng0,
77 Rng1 && rng1,
78 C pred = C{},
79 P0 proj0 = P0{},
80 P1 proj1 = P1{}) //
81 {
82 return (*this)(begin(rng0),
83 end(rng0),
84 begin(rng1),
85 end(rng1),
86 std::move(pred),
87 std::move(proj0),
88 std::move(proj1));
89 }
90
91 RANGES_FUNC_END(lexicographical_compare)
92
93 namespace cpp20
94 {
95 using ranges::lexicographical_compare;
96 }
98} // namespace ranges
99
100#include <range/v3/detail/epilogue.hpp>
101
102#endif
The indirect_strict_weak_order concept.
The input_iterator concept.
The input_range concept.
The sentinel_for concept.
decltype(begin(declval(Rng &))) iterator_t
Definition access.hpp:698
typename Fn::template invoke< Args... > invoke
Evaluate the invocable Fn with the arguments Args.
Definition meta.hpp:541
Definition identity.hpp:25
Definition comparisons.hpp:50