File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed
libcxx/include/__algorithm Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change 1010#ifndef _LIBCPP___ALGORITHM_ALL_OF_H
1111#define _LIBCPP___ALGORITHM_ALL_OF_H
1212
13+ #include < __algorithm/any_of.h>
1314#include < __config>
1415#include < __functional/identity.h>
1516#include < __type_traits/invoke.h>
17+ #include < __utility/move.h>
1618
1719#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1820# pragma GCC system_header
@@ -23,11 +25,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2325template <class _Iter , class _Sent , class _Proj , class _Pred >
2426_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
2527__all_of (_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
26- for (; __first != __last; ++__first) {
27- if (!std::__invoke (__pred, std::__invoke (__proj, *__first)))
28- return false ;
29- }
30- return true ;
28+ using _Ref = decltype (std::__invoke (__proj, *__first));
29+ return !std::__any_of (
30+ std::move (__first),
31+ std::move (__last),
32+ [&__pred](_Ref __arg) { return !std::__invoke (__pred, std::forward<_Ref>(__arg)); },
33+ __proj);
3134}
3235
3336template <class _InputIterator , class _Predicate >
Original file line number Diff line number Diff line change 1010#ifndef _LIBCPP___ALGORITHM_NONE_OF_H
1111#define _LIBCPP___ALGORITHM_NONE_OF_H
1212
13+ #include < __algorithm/any_of.h>
1314#include < __config>
1415
1516#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -21,10 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2122template <class _InputIterator , class _Predicate >
2223[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
2324none_of (_InputIterator __first, _InputIterator __last, _Predicate __pred) {
24- for (; __first != __last; ++__first)
25- if (__pred (*__first))
26- return false ;
27- return true ;
25+ return !std::any_of (__first, __last, __pred);
2826}
2927
3028_LIBCPP_END_NAMESPACE_STD
You can’t perform that action at this time.
0 commit comments