File indexing completed on 2026-05-03 08:13:07
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _LIBCPP___ALGORITHM_ADJACENT_FIND_H
0011 #define _LIBCPP___ALGORITHM_ADJACENT_FIND_H
0012
0013 #include <__algorithm/comp.h>
0014 #include <__config>
0015 #include <__functional/identity.h>
0016 #include <__type_traits/invoke.h>
0017 #include <__utility/move.h>
0018
0019 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0020 # pragma GCC system_header
0021 #endif
0022
0023 _LIBCPP_PUSH_MACROS
0024 #include <__undef_macros>
0025
0026 _LIBCPP_BEGIN_NAMESPACE_STD
0027
0028 template <class _Iter, class _Sent, class _Pred, class _Proj>
0029 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter
0030 __adjacent_find(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
0031 if (__first == __last)
0032 return __first;
0033
0034 _Iter __i = __first;
0035 while (++__i != __last) {
0036 if (std::__invoke(__pred, std::__invoke(__proj, *__first), std::__invoke(__proj, *__i)))
0037 return __first;
0038 __first = __i;
0039 }
0040 return __i;
0041 }
0042
0043 template <class _ForwardIterator, class _BinaryPredicate>
0044 [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
0045 adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {
0046 __identity __proj;
0047 return std::__adjacent_find(std::move(__first), std::move(__last), __pred, __proj);
0048 }
0049
0050 template <class _ForwardIterator>
0051 [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
0052 adjacent_find(_ForwardIterator __first, _ForwardIterator __last) {
0053 return std::adjacent_find(std::move(__first), std::move(__last), __equal_to());
0054 }
0055
0056 _LIBCPP_END_NAMESPACE_STD
0057
0058 _LIBCPP_POP_MACROS
0059
0060 #endif