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_FIND_FIRST_OF_H
11 #define _LIBCPP___ALGORITHM_FIND_FIRST_OF_H
13 #include <__algorithm/comp.h>
15 #include <__iterator/iterator_traits.h>
17 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18 # pragma GCC system_header
21 _LIBCPP_BEGIN_NAMESPACE_STD
23 template <class _ForwardIterator1
, class _ForwardIterator2
, class _BinaryPredicate
>
25 _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator1
__find_first_of_ce(_ForwardIterator1 __first1
,
26 _ForwardIterator1 __last1
,
27 _ForwardIterator2 __first2
,
28 _ForwardIterator2 __last2
,
29 _BinaryPredicate
&& __pred
) {
30 for (; __first1
!= __last1
; ++__first1
)
31 for (_ForwardIterator2 __j
= __first2
; __j
!= __last2
; ++__j
)
32 if (__pred(*__first1
, *__j
))
37 template <class _ForwardIterator1
, class _ForwardIterator2
, class _BinaryPredicate
>
38 _LIBCPP_NODISCARD_EXT
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1
39 find_first_of(_ForwardIterator1 __first1
, _ForwardIterator1 __last1
, _ForwardIterator2 __first2
,
40 _ForwardIterator2 __last2
, _BinaryPredicate __pred
) {
41 return _VSTD::__find_first_of_ce(__first1
, __last1
, __first2
, __last2
, __pred
);
44 template <class _ForwardIterator1
, class _ForwardIterator2
>
45 _LIBCPP_NODISCARD_EXT
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1
find_first_of(
46 _ForwardIterator1 __first1
, _ForwardIterator1 __last1
, _ForwardIterator2 __first2
, _ForwardIterator2 __last2
) {
47 return std::__find_first_of_ce(__first1
, __last1
, __first2
, __last2
, __equal_to());
50 _LIBCPP_END_NAMESPACE_STD
52 #endif // _LIBCPP___ALGORITHM_FIND_FIRST_OF_H