[libcxx-commits] [libcxx] [libc++][pstl] Default implementation of parallel std::adjacent_difference (PR #207585)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jul 8 08:48:28 PDT 2026
================
@@ -529,6 +530,34 @@ struct __rotate_copy<__default_backend_tag, _ExecutionPolicy> {
}
};
+template <class _ExecutionPolicy>
+struct __adjacent_difference<__default_backend_tag, _ExecutionPolicy> {
+ template <class _Policy, class _ForwardIterator1, class _ForwardIterator2, class _BinaryOperation>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardIterator2>
+ operator()(_Policy&& __policy,
+ _ForwardIterator1 __first1,
+ _ForwardIterator1 __last1,
+ _ForwardIterator2 __first2,
+ _BinaryOperation&& __op) const noexcept {
+ using _TransformBinary = __dispatch<__transform_binary, __current_configuration, _ExecutionPolicy>;
+ if (__first1 == __last1)
+ return __first2; // edge case: empty input range, just return the output iterator
+ *__first2 = *__first1;
+ ++__first2;
+ _ForwardIterator1 __first_left = std::next(__first1);
----------------
ldionne wrote:
I would suggest using `__first2` here (that name will be free if you rename the output iterator).
https://github.com/llvm/llvm-project/pull/207585
More information about the libcxx-commits
mailing list