Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:20

0001 //===----------------------------------------------------------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef _LIBCPP___CXX03___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H
0010 #define _LIBCPP___CXX03___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H
0011 
0012 #include <__cxx03/__config>
0013 #include <__cxx03/__functional/identity.h>
0014 #include <__cxx03/__functional/invoke.h>
0015 #include <__cxx03/__functional/ranges_operations.h>
0016 #include <__cxx03/__iterator/concepts.h>
0017 #include <__cxx03/__iterator/projected.h>
0018 #include <__cxx03/__ranges/access.h>
0019 #include <__cxx03/__ranges/concepts.h>
0020 #include <__cxx03/__utility/move.h>
0021 
0022 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0023 #  pragma GCC system_header
0024 #endif
0025 
0026 _LIBCPP_PUSH_MACROS
0027 #include <__cxx03/__undef_macros>
0028 
0029 #if _LIBCPP_STD_VER >= 20
0030 
0031 _LIBCPP_BEGIN_NAMESPACE_STD
0032 
0033 namespace ranges {
0034 namespace __lexicographical_compare {
0035 struct __fn {
0036   template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Proj1, class _Proj2, class _Comp>
0037   _LIBCPP_HIDE_FROM_ABI constexpr static bool __lexicographical_compare_impl(
0038       _Iter1 __first1,
0039       _Sent1 __last1,
0040       _Iter2 __first2,
0041       _Sent2 __last2,
0042       _Comp& __comp,
0043       _Proj1& __proj1,
0044       _Proj2& __proj2) {
0045     while (__first2 != __last2) {
0046       if (__first1 == __last1 || std::invoke(__comp, std::invoke(__proj1, *__first1), std::invoke(__proj2, *__first2)))
0047         return true;
0048       if (std::invoke(__comp, std::invoke(__proj2, *__first2), std::invoke(__proj1, *__first1)))
0049         return false;
0050       ++__first1;
0051       ++__first2;
0052     }
0053     return false;
0054   }
0055 
0056   template <input_iterator _Iter1,
0057             sentinel_for<_Iter1> _Sent1,
0058             input_iterator _Iter2,
0059             sentinel_for<_Iter2> _Sent2,
0060             class _Proj1                                                                           = identity,
0061             class _Proj2                                                                           = identity,
0062             indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less>
0063   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
0064       _Iter1 __first1,
0065       _Sent1 __last1,
0066       _Iter2 __first2,
0067       _Sent2 __last2,
0068       _Comp __comp   = {},
0069       _Proj1 __proj1 = {},
0070       _Proj2 __proj2 = {}) const {
0071     return __lexicographical_compare_impl(
0072         std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), __comp, __proj1, __proj2);
0073   }
0074 
0075   template <input_range _Range1,
0076             input_range _Range2,
0077             class _Proj1 = identity,
0078             class _Proj2 = identity,
0079             indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>>
0080                 _Comp = ranges::less>
0081   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
0082       _Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
0083     return __lexicographical_compare_impl(
0084         ranges::begin(__range1),
0085         ranges::end(__range1),
0086         ranges::begin(__range2),
0087         ranges::end(__range2),
0088         __comp,
0089         __proj1,
0090         __proj2);
0091   }
0092 };
0093 } // namespace __lexicographical_compare
0094 
0095 inline namespace __cpo {
0096 inline constexpr auto lexicographical_compare = __lexicographical_compare::__fn{};
0097 } // namespace __cpo
0098 } // namespace ranges
0099 
0100 _LIBCPP_END_NAMESPACE_STD
0101 
0102 #endif // _LIBCPP_STD_VER >= 20
0103 
0104 _LIBCPP_POP_MACROS
0105 
0106 #endif // _LIBCPP___CXX03___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H