[libcxx-commits] [libcxx] [libc++][pstl] Generic implementation of parallel std::is_sorted (PR #176129)

Michael G. Kazakov via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jan 24 03:37:35 PST 2026


================
@@ -388,6 +390,36 @@ struct __reduce<__default_backend_tag, _ExecutionPolicy> {
   }
 };
 
+template <class _ExecutionPolicy>
+struct __is_sorted<__default_backend_tag, _ExecutionPolicy> {
+  template <class _Policy, class _ForwardIterator, class _Comp>
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool>
+  operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Comp&& __comp) const noexcept {
+    if constexpr (__has_bidirectional_iterator_category<_ForwardIterator>::value) {
+      if (__first == __last)
+        return true; // Empty, sorted by definition
+      _ForwardIterator __first2 = __first;
+      ++__first2; // __first2 = __first + 1
----------------
mikekazakov wrote:

Done.

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


More information about the libcxx-commits mailing list