brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · ac23323 Raw
58 lines · c
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-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCPP___CXX03___ALGORITHM_ADJACENT_FIND_H11#define _LIBCPP___CXX03___ALGORITHM_ADJACENT_FIND_H12 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_header21#endif22 23_LIBCPP_PUSH_MACROS24#include <__cxx03/__undef_macros>25 26_LIBCPP_BEGIN_NAMESPACE_STD27 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 _ForwardIterator43adjacent_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 _ForwardIterator49adjacent_find(_ForwardIterator __first, _ForwardIterator __last) {50  return std::adjacent_find(std::move(__first), std::move(__last), __equal_to());51}52 53_LIBCPP_END_NAMESPACE_STD54 55_LIBCPP_POP_MACROS56 57#endif // _LIBCPP___CXX03___ALGORITHM_ADJACENT_FIND_H58