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___ALGORITHM_FIND_IF_NOT_H
11#define _LIBCPP___ALGORITHM_FIND_IF_NOT_H
12
13#include <__algorithm/find_if.h>
14#include <__config>
15#include <__functional/identity.h>
16#include <__type_traits/invoke.h>
17#include <__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 <__undef_macros>
25
26_LIBCPP_BEGIN_NAMESPACE_STD
27
28template <class _Iter, class _Sent, class _Pred, class _Proj>
29_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter
30__find_if_not(_Iter __first, _Sent __last, _Pred&& __pred, _Proj&& __proj) {
31 return std::__find_if(
32 std::move(__first),
33 std::move(__last),
34 [&]<class _ValT>(_ValT&& __val) -> bool { return !std::__invoke(__pred, __val); },
35 __proj);
36}
37
38template <class _InputIterator, class _Predicate>
39[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
40find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
41 return std::__find_if_not(__first, __last, __pred, __identity());
42}
43
44_LIBCPP_END_NAMESPACE_STD
45
46_LIBCPP_POP_MACROS
47
48#endif // _LIBCPP___ALGORITHM_FIND_IF_NOT_H
49