2 //===----------------------------------------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___ALGORITHM_ADJACENT_FIND_H
11 #define _LIBCPP___ALGORITHM_ADJACENT_FIND_H
13 #include <__cxx03/__algorithm/comp.h>
14 #include <__cxx03/__algorithm/iterator_operations.h>
15 #include <__cxx03/__config>
16 #include <__cxx03/__iterator/iterator_traits.h>
17 #include <__cxx03/__utility/move.h>
19 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20 # pragma GCC system_header
24 #include <__cxx03/__undef_macros>
26 _LIBCPP_BEGIN_NAMESPACE_STD
28 template <class _Iter
, class _Sent
, class _BinaryPredicate
>
29 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter
30 __adjacent_find(_Iter __first
, _Sent __last
, _BinaryPredicate
&& __pred
) {
31 if (__first
== __last
)
34 while (++__i
!= __last
) {
35 if (__pred(*__first
, *__i
))
42 template <class _ForwardIterator
, class _BinaryPredicate
>
43 _LIBCPP_NODISCARD
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
44 adjacent_find(_ForwardIterator __first
, _ForwardIterator __last
, _BinaryPredicate __pred
) {
45 return std::__adjacent_find(std::move(__first
), std::move(__last
), __pred
);
48 template <class _ForwardIterator
>
49 _LIBCPP_NODISCARD
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
50 adjacent_find(_ForwardIterator __first
, _ForwardIterator __last
) {
51 return std::adjacent_find(std::move(__first
), std::move(__last
), __equal_to());
54 _LIBCPP_END_NAMESPACE_STD
58 #endif // _LIBCPP___ALGORITHM_ADJACENT_FIND_H