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

Add CPOs for for_each #4867

Merged
merged 1 commit into from
Aug 13, 2020
Merged

Add CPOs for for_each #4867

merged 1 commit into from
Aug 13, 2020

Conversation

msimberg
Copy link
Contributor

Adds CPOs for hpx::for_each and hpx::ranges::for_each. As discussed earlier, I've tried to follow the return types in the standard as closely as possible (leaving out the function when an execution policy is used). The return types are adjusted only in the tag_invoke(for_each_t, ...) overloads (unlike what I thought initially would need to be adjusted, namely struct for_each(_n) or the foreach partitioner).

The return types are as follows:

policy hpx::for_each hpx::ranges::for_each hpx::for_each_n hpx::ranges::for_each_n
no policy F in_fun_result iter in_fun_result
non-task policy void iter* iter iter*
task policy future<void>* future<iter>* future<iter>* future<iter>*

where iter is the iterator type of the input or corresponding to the input range. * is not in the standard. We could keep iter as the return type for the non-task policy hpx::for_each, even though this is different than the standard.

The iterators were restricted by is_iterator with SFINAE, but then in the body of for_each there was a static_assert(is_input/forward_iterator). I've change this to only use is_input/forward_iterator in the template parameter list. Was the static assert there only for better error messages or also for some other reason?

@msimberg msimberg added this to the 1.5.0 milestone Jul 28, 2020
@msimberg msimberg requested a review from K-ballo July 28, 2020 14:16
@hkaiser
Copy link
Member

hkaiser commented Jul 28, 2020

The iterators were restricted by is_iterator with SFINAE, but then in the body of for_each there was a static_assert(is_input/forward_iterator). I've change this to only use is_input/forward_iterator in the template parameter list. Was the static assert there only for better error messages or also for some other reason?

These were used for better error messages.

@hkaiser hkaiser mentioned this pull request Jul 28, 2020
51 tasks
@msimberg msimberg force-pushed the for-each-cpo branch 5 times, most recently from 2e167ee to 0bbfb3c Compare July 29, 2020 09:58
hkaiser
hkaiser previously approved these changes Jul 29, 2020
Copy link
Member

@hkaiser hkaiser left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

aurianer
aurianer previously approved these changes Aug 6, 2020
Copy link
Contributor

@aurianer aurianer left a comment

Choose a reason for hiding this comment

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

LGTM thanks!

@msimberg
Copy link
Contributor Author

retest

@msimberg msimberg merged commit a11a5fa into STEllAR-GROUP:master Aug 13, 2020
@msimberg msimberg deleted the for-each-cpo branch August 13, 2020 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants