[rtsan] Remove mkfifoat interceptor (#116997)
[llvm-project.git] / libcxx / include / __algorithm / adjacent_find.h
blob76728900bd4d97aa5c57d934e72b9e51468da905
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 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___ALGORITHM_ADJACENT_FIND_H
11 #define _LIBCPP___ALGORITHM_ADJACENT_FIND_H
13 #include <__algorithm/comp.h>
14 #include <__algorithm/iterator_operations.h>
15 #include <__config>
16 #include <__functional/identity.h>
17 #include <__iterator/iterator_traits.h>
18 #include <__type_traits/invoke.h>
19 #include <__utility/move.h>
21 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22 # pragma GCC system_header
23 #endif
25 _LIBCPP_PUSH_MACROS
26 #include <__undef_macros>
28 _LIBCPP_BEGIN_NAMESPACE_STD
30 template <class _Iter, class _Sent, class _Pred, class _Proj>
31 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter
32 __adjacent_find(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
33 if (__first == __last)
34 return __first;
36 _Iter __i = __first;
37 while (++__i != __last) {
38 if (std::__invoke(__pred, std::__invoke(__proj, *__first), std::__invoke(__proj, *__i)))
39 return __first;
40 __first = __i;
42 return __i;
45 template <class _ForwardIterator, class _BinaryPredicate>
46 [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
47 adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {
48 __identity __proj;
49 return std::__adjacent_find(std::move(__first), std::move(__last), __pred, __proj);
52 template <class _ForwardIterator>
53 [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
54 adjacent_find(_ForwardIterator __first, _ForwardIterator __last) {
55 return std::adjacent_find(std::move(__first), std::move(__last), __equal_to());
58 _LIBCPP_END_NAMESPACE_STD
60 _LIBCPP_POP_MACROS
62 #endif // _LIBCPP___ALGORITHM_ADJACENT_FIND_H