8000 [stdpar][algorithms] Add support for `unique_copy` and `unique` by normallytangent · Pull Request #1831 · AdaptiveCpp/AdaptiveCpp · GitHub
[go: up one dir, main page]

Skip to content

Conversation

normallytangent
Copy link
Collaborator

This PR adds automatic offloading support for unique_copy and unique.

  • Does not use copy_if interface, although unique internally implements the same logic. This is because the lambda 'pred' needs to operate upon the iterator. Since in copy_if the predicate is called with a value, the interface is not readily usable for unique_copy and unique algorithms.
  • Overloads with the binary predicate are implemented and tested.

@normallytangent normallytangent requested a review from illuhad July 16, 2025 14:48
@normallytangent
Copy link
Collaborator Author

@illuhad updated and ready 👍


auto pred = [first, p](auto x) {
auto input = x;
--input;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this well-defined if input is the first element?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, the if-condition on the next line checks for that case.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but that's my question: Is it always well-defined to decrement any iterator below begin? Maybe the iterator behaves like an unsigned int and then encounters some underflow behavior or so which may be UB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0