File indexing completed on 2026-05-03 08:13:17
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _LIBCPP___CXX03___ALGORITHM_ADJACENT_FIND_H
0011 #define _LIBCPP___CXX03___ALGORITHM_ADJACENT_FIND_H
0012
0013 #include <__cxx03/__algorithm/comp.h>
0014 #include <__cxx03/__algorithm/iterator_operations.h>
0015 #include <__cxx03/__config>
0016 #include <__cxx03/__iterator/iterator_traits.h>
0017 #include <__cxx03/__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 <__cxx03/__undef_macros>
0025
0026 _LIBCPP_BEGIN_NAMESPACE_STD
0027
0028 template <class _Iter, class _Sent, class _BinaryPredicate>
0029 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter
0030 __adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
0031 if (__first == __last)
0032 return __first;
0033 _Iter __i = __first;
0034 while (++__i != __last) {
0035 if (__pred(*__first, *__i))
0036 return __first;
0037 __first = __i;
0038 }
0039 return __i;
0040 }
0041
0042 template <class _ForwardIterator, class _BinaryPredicate>
0043 _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
0044 adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {
0045 return std::__adjacent_find(std::move(__first), std::move(__last), __pred);
0046 }
0047
0048 template <class _ForwardIterator>
0049 _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
0050 adjacent_find(_ForwardIterator __first, _ForwardIterator __last) {
0051 return std::adjacent_find(std::move(__first), std::move(__last), __equal_to());
0052 }
0053
0054 _LIBCPP_END_NAMESPACE_STD
0055
0056 _LIBCPP_POP_MACROS
0057
0058 #endif