brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.7 KiB · ec12b0c Raw
108 lines · c
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef _LIBCPP___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H10#define _LIBCPP___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H11 12#include <__algorithm/lexicographical_compare.h>13#include <__algorithm/unwrap_range.h>14#include <__config>15#include <__functional/identity.h>16#include <__functional/invoke.h>17#include <__functional/ranges_operations.h>18#include <__iterator/concepts.h>19#include <__iterator/projected.h>20#include <__ranges/access.h>21#include <__ranges/concepts.h>22#include <__utility/move.h>23 24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)25#  pragma GCC system_header26#endif27 28_LIBCPP_PUSH_MACROS29#include <__undef_macros>30 31#if _LIBCPP_STD_VER >= 2032 33_LIBCPP_BEGIN_NAMESPACE_STD34 35namespace ranges {36struct __lexicographical_compare {37  template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Proj1, class _Proj2, class _Comp>38  static _LIBCPP_HIDE_FROM_ABI constexpr bool __lexicographical_compare_unwrap(39      _Iter1 __first1,40      _Sent1 __last1,41      _Iter2 __first2,42      _Sent2 __last2,43      _Comp& __comp,44      _Proj1& __proj1,45      _Proj2& __proj2) {46    auto [__first1_un, __last1_un] = std::__unwrap_range(std::move(__first1), std::move(__last1));47    auto [__first2_un, __last2_un] = std::__unwrap_range(std::move(__first2), std::move(__last2));48    return std::__lexicographical_compare(49        std::move(__first1_un),50        std::move(__last1_un),51        std::move(__first2_un),52        std::move(__last2_un),53        __comp,54        __proj1,55        __proj2);56  }57 58  template <input_iterator _Iter1,59            sentinel_for<_Iter1> _Sent1,60            input_iterator _Iter2,61            sentinel_for<_Iter2> _Sent2,62            class _Proj1                                                                           = identity,63            class _Proj2                                                                           = identity,64            indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less>65  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(66      _Iter1 __first1,67      _Sent1 __last1,68      _Iter2 __first2,69      _Sent2 __last2,70      _Comp __comp   = {},71      _Proj1 __proj1 = {},72      _Proj2 __proj2 = {}) const {73    return __lexicographical_compare_unwrap(74        std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), __comp, __proj1, __proj2);75  }76 77  template <input_range _Range1,78            input_range _Range2,79            class _Proj1 = identity,80            class _Proj2 = identity,81            indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>>82                _Comp = ranges::less>83  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(84      _Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {85    return __lexicographical_compare_unwrap(86        ranges::begin(__range1),87        ranges::end(__range1),88        ranges::begin(__range2),89        ranges::end(__range2),90        __comp,91        __proj1,92        __proj2);93  }94};95 96inline namespace __cpo {97inline constexpr auto lexicographical_compare = __lexicographical_compare{};98} // namespace __cpo99} // namespace ranges100 101_LIBCPP_END_NAMESPACE_STD102 103#endif // _LIBCPP_STD_VER >= 20104 105_LIBCPP_POP_MACROS106 107#endif // _LIBCPP___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H108