[libcxx-commits] [libcxx] [libc++][pstl] Default implementation of parallel std::find_first_of (PR #206328)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 8 08:17:57 PDT 2026


================
@@ -181,6 +186,30 @@ struct __is_partitioned<__default_backend_tag, _ExecutionPolicy> {
   }
 };
 
+template <class _ExecutionPolicy>
+struct __find_first_of<__default_backend_tag, _ExecutionPolicy> {
+  template <class _Policy, class _ForwardIterator1, class _ForwardIterator2, class _Predicate>
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardIterator1>
+  operator()(_Policy&& __policy,
+             _ForwardIterator1 __first1,
+             _ForwardIterator1 __last1,
+             _ForwardIterator2 __first2,
+             _ForwardIterator2 __last2,
+             _Predicate&& __pred) const noexcept {
+    using _FindIf = __dispatch<__find_if, __current_configuration, _ExecutionPolicy>;
+    using _Ref1   = __iterator_reference<_ForwardIterator1>;
+    using _Ref2   = __iterator_reference<_ForwardIterator2>;
+    return _FindIf()(__policy, std::move(__first1), std::move(__last1), [&](_Ref1 __element) {
+      if constexpr (__desugars_to_v<__equal_tag, _Predicate, __remove_cvref_t<_Ref1>, __remove_cvref_t<_Ref2>>) {
----------------
ldionne wrote:

Note that the above is actually incorrect: `__desugars_to` DOES NOT strip cv refs on the argument types. However, we do intend to pass real argument types to it, not cv-ref stripped types.

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


More information about the libcxx-commits mailing list