Skip to content

Commit 95937e6

Browse files
Change the implementation of std::find_first_of.h to use any_of #129319
1 parent 6c9a9d9 commit 95937e6

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

libcxx/include/__algorithm/find_first_of.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator1 __find_fir
2626
_ForwardIterator2 __first2,
2727
_ForwardIterator2 __last2,
2828
_BinaryPredicate&& __pred) {
29-
for (; __first1 != __last1; ++__first1)
30-
for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j)
31-
if (__pred(*__first1, *__j))
32-
return __first1;
33-
return __last1;
29+
return std::find_if(first1, last1, [&](const auto& x) {
30+
return std::any_of(first2, last2, [&](const auto& y) { return x == y; });
31+
});
3432
}
3533

3634
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>

0 commit comments

Comments
 (0)