Warning: This file is not a C or C++ file. It does not have highlighting.

1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
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
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___CXX03___ALGORITHM_ADJACENT_FIND_H
11#define _LIBCPP___CXX03___ALGORITHM_ADJACENT_FIND_H
12
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>
18
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21#endif
22
23_LIBCPP_PUSH_MACROS
24#include <__cxx03/__undef_macros>
25
26_LIBCPP_BEGIN_NAMESPACE_STD
27
28template <class _Iter, class _Sent, class _BinaryPredicate>
29_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _Iter __adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
30 if (__first == __last)
31 return __first;
32 _Iter __i = __first;
33 while (++__i != __last) {
34 if (__pred(*__first, *__i))
35 return __first;
36 __first = __i;
37 }
38 return __i;
39}
40
41template <class _ForwardIterator, class _BinaryPredicate>
42_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator
43adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {
44 return std::__adjacent_find(std::move(__first), std::move(__last), __pred);
45}
46
47template <class _ForwardIterator>
48_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator
49adjacent_find(_ForwardIterator __first, _ForwardIterator __last) {
50 return std::adjacent_find(std::move(__first), std::move(__last), __equal_to());
51}
52
53_LIBCPP_END_NAMESPACE_STD
54
55_LIBCPP_POP_MACROS
56
57#endif // _LIBCPP___CXX03___ALGORITHM_ADJACENT_FIND_H
58

Warning: This file is not a C or C++ file. It does not have highlighting.

source code of libcxx/include/__cxx03/__algorithm/adjacent_find.h