Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:27:54

0001 /// \file
0002 // Range v3 library
0003 //
0004 //  Copyright Eric Niebler 2013-present
0005 //
0006 //  Use, modification and distribution is subject to the
0007 //  Boost Software License, Version 1.0. (See accompanying
0008 //  file LICENSE_1_0.txt or copy at
0009 //  http://www.boost.org/LICENSE_1_0.txt)
0010 //
0011 // Project home: https://github.com/ericniebler/range-v3
0012 //
0013 #ifndef RANGES_V3_ALGORITHM_LEXICOGRAPHICAL_COMPARE_HPP
0014 #define RANGES_V3_ALGORITHM_LEXICOGRAPHICAL_COMPARE_HPP
0015 
0016 #include <range/v3/range_fwd.hpp>
0017 
0018 #include <range/v3/functional/comparisons.hpp>
0019 #include <range/v3/functional/identity.hpp>
0020 #include <range/v3/functional/invoke.hpp>
0021 #include <range/v3/iterator/concepts.hpp>
0022 #include <range/v3/iterator/traits.hpp>
0023 #include <range/v3/range/access.hpp>
0024 #include <range/v3/range/concepts.hpp>
0025 #include <range/v3/range/traits.hpp>
0026 #include <range/v3/utility/static_const.hpp>
0027 
0028 #include <range/v3/detail/prologue.hpp>
0029 
0030 namespace ranges
0031 {
0032     /// \addtogroup group-algorithms
0033     /// @{
0034     RANGES_FUNC_BEGIN(lexicographical_compare)
0035 
0036         /// \brief function template \c lexicographical_compare
0037         template(typename I0,
0038                  typename S0,
0039                  typename I1,
0040                  typename S1,
0041                  typename C = less,
0042                  typename P0 = identity,
0043                  typename P1 = identity)(
0044             requires input_iterator<I0> AND sentinel_for<S0, I0> AND
0045                 input_iterator<I1> AND sentinel_for<S1, I1> AND
0046                 indirect_strict_weak_order<C, projected<I0, P0>, projected<I1, P1>>)
0047         constexpr bool RANGES_FUNC(lexicographical_compare)(I0 begin0,
0048                                                             S0 end0,
0049                                                             I1 begin1,
0050                                                             S1 end1,
0051                                                             C pred = C{},
0052                                                             P0 proj0 = P0{},
0053                                                             P1 proj1 = P1{})
0054         {
0055             for(; begin1 != end1; ++begin0, ++begin1)
0056             {
0057                 if(begin0 == end0 ||
0058                    invoke(pred, invoke(proj0, *begin0), invoke(proj1, *begin1)))
0059                     return true;
0060                 if(invoke(pred, invoke(proj1, *begin1), invoke(proj0, *begin0)))
0061                     return false;
0062             }
0063             return false;
0064         }
0065 
0066         /// \overload
0067         template(typename Rng0,
0068                  typename Rng1,
0069                  typename C = less,
0070                  typename P0 = identity,
0071                  typename P1 = identity)(
0072             requires input_range<Rng0> AND input_range<Rng1> AND
0073                 indirect_strict_weak_order<C,
0074                                            projected<iterator_t<Rng0>, P0>,
0075                                            projected<iterator_t<Rng1>, P1>>)
0076         constexpr bool RANGES_FUNC(lexicographical_compare)(Rng0 && rng0, 
0077                                                             Rng1 && rng1, 
0078                                                             C pred = C{}, 
0079                                                             P0 proj0 = P0{}, 
0080                                                             P1 proj1 = P1{}) //
0081         {
0082             return (*this)(begin(rng0),
0083                            end(rng0),
0084                            begin(rng1),
0085                            end(rng1),
0086                            std::move(pred),
0087                            std::move(proj0),
0088                            std::move(proj1));
0089         }
0090 
0091     RANGES_FUNC_END(lexicographical_compare)
0092 
0093     namespace cpp20
0094     {
0095         using ranges::lexicographical_compare;
0096     }
0097     /// @}
0098 } // namespace ranges
0099 
0100 #include <range/v3/detail/epilogue.hpp>
0101 
0102 #endif