[libcxx-commits] [libcxx] [libc++] Forward std::all_of and std::none_of to std::any_of (PR #167670)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Nov 22 06:46: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)); };
----------------
huixie90 wrote:
can avoid the explicit template parameter like
```
auto __negated_pred = [&__pred](auto&& __arg) -> bool { return !std::__invoke(__pred, std::forward<decltype(__arg)>(__arg)); };
```
https://github.com/llvm/llvm-project/pull/167670
More information about the libcxx-commits
mailing list