[libcxx-commits] [libcxx] [libc++] Forward find* algorithms to find_if (PR #179938)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Mon Feb 23 09:51:08 PST 2026


================
@@ -48,10 +49,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 template <class _Iter, class _Sent, class _Tp, class _Proj>
 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter
 __find_loop(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) {
-  for (; __first != __last; ++__first)
-    if (std::__invoke(__proj, *__first) == __value)
-      break;
-  return __first;
+  return std::__find_if(
----------------
ldionne wrote:

This is a bit tricky: this function explicitly advertises that it's implemented as a loop, and it's arguably important for that to be the case for the optimization logic below. Switching to `__find_if` means that this might not be the case anymore if we optimize `__find_if`.

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


More information about the libcxx-commits mailing list