[libcxx-commits] [libcxx] [libc++] Forward std::all_of and std::none_of to std::any_of (PR #167670)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Mon Nov 24 01:52:42 PST 2025


================
@@ -23,11 +25,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 template <class _Iter, class _Sent, class _Proj, class _Pred>
 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
 __all_of(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
-  for (; __first != __last; ++__first) {
-    if (!std::__invoke(__pred, std::__invoke(__proj, *__first)))
-      return false;
-  }
-  return true;
+  using _Ref          = decltype(std::__invoke(__proj, *__first));
+  auto __wrapped_pred = [&__pred](_Ref __arg) { return !std::__invoke(__pred, std::forward<_Ref>(__arg)); };
----------------
philnik777 wrote:

That's ill-formed before C++14: https://godbolt.org/z/nW9WvTT66

https://github.com/llvm/llvm-project/pull/167670


More information about the libcxx-commits mailing list