[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 1 09:48:14 PDT 2026
================
@@ -0,0 +1,113 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: std-at-least-c++17
+
+// UNSUPPORTED: libcpp-has-no-incomplete-pstl
+
+// template <class ExecutionPolicy,
+// class ForwardIterator1,
+// class ForwardIterator2>
+// ForwardIterator1 find_first_of(ExecutionPolicy&& exec,
+// ForwardIterator1 first1,
+// ForwardIterator1 last1,
+// ForwardIterator2 first2,
+// ForwardIterator2 last2);
+
+#include <algorithm>
+#include <cassert>
+#include <functional>
+#include <iterator>
+#include <limits>
+#include <numeric>
+
+#include "test_execution_policies.h"
+#include "test_iterators.h"
+#include "test_macros.h"
+#include "type_algorithms.h"
+
+EXECUTION_POLICY_SFINAE_TEST(find_first_of);
+
+static_assert(sfinae_test_find_first_of<int, int*, int*, int*, int*>);
+static_assert(!sfinae_test_find_first_of<std::execution::parallel_policy, int*, int*, int*, int*>);
+
+template <class Callable>
+void runway_sample(size_t size, Callable&& callable) {
----------------
ldionne wrote:
```suggestion
void runway_sample(size_t size, Callable callable) {
```
Unless there's a reason we might want to forward the callable (or avoid making a copy), I'd keep the most naive/simplest way to pass this. Otherwise, one wonders if there's a deeper reason for taking by ref, when in reality there's none (AFAICT).
https://github.com/llvm/llvm-project/pull/206328
More information about the libcxx-commits
mailing list