Path: blob/main/contrib/llvm-project/libcxx/include/__algorithm/lexicographical_compare.h
35233 views
//===----------------------------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H9#define _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H1011#include <__algorithm/comp.h>12#include <__algorithm/comp_ref_type.h>13#include <__config>14#include <__iterator/iterator_traits.h>1516#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17# pragma GCC system_header18#endif1920_LIBCPP_BEGIN_NAMESPACE_STD2122template <class _Compare, class _InputIterator1, class _InputIterator2>23_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __lexicographical_compare(24_InputIterator1 __first1,25_InputIterator1 __last1,26_InputIterator2 __first2,27_InputIterator2 __last2,28_Compare __comp) {29for (; __first2 != __last2; ++__first1, (void)++__first2) {30if (__first1 == __last1 || __comp(*__first1, *__first2))31return true;32if (__comp(*__first2, *__first1))33return false;34}35return false;36}3738template <class _InputIterator1, class _InputIterator2, class _Compare>39_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool lexicographical_compare(40_InputIterator1 __first1,41_InputIterator1 __last1,42_InputIterator2 __first2,43_InputIterator2 __last2,44_Compare __comp) {45return std::__lexicographical_compare<__comp_ref_type<_Compare> >(__first1, __last1, __first2, __last2, __comp);46}4748template <class _InputIterator1, class _InputIterator2>49_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool lexicographical_compare(50_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {51return std::lexicographical_compare(__first1, __last1, __first2, __last2, __less<>());52}5354_LIBCPP_END_NAMESPACE_STD5556#endif // _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H575859