Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for non-default-constructible iterators in std::for_each_n #1132

Merged

Conversation

nilsfriess
Copy link
Collaborator

@nilsfriess nilsfriess commented Sep 12, 2023

When the macro HIPSYCL_STDPAR_OFFLOAD is used in std::for_each_n, the type return_type is ForwardIt (in the C++ standard it is called InputIt) and this iterator only has to meet the requirements of a LegacyInputIterator which does not include default-constructibility. By replacing the if/else with a ternary operator, the declaration that causes a call to the (possibly non-existent) default constructor can be removed.

Edit: I just realised that I accidentally removed a call to q.wait() in the second macro; ill fix that asap. Fixed it.

… `return_type`

When the macro `HIPSYCL_STDPAR_OFFLOAD` is used in `std::for_each_n`,
the type `return_type` is `ForwardIt` (in the C++ standard it is
called `InputIt`) and this iterator only has to meet the requirements
of a `LegacyInputIterator` which does not include default-constructibility.
By replacing the if/else with a ternary operator, the declaration that
tries to call the default constructor can be removed.
Copy link
Collaborator

@illuhad illuhad left a comment

Choose a reason for hiding this comment

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

Thanks!

@illuhad illuhad merged commit 3328285 into AdaptiveCpp:develop Sep 13, 2023
17 of 18 checks passed
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.

None yet

2 participants