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
Take advantage of C++14 lambda capture initialization syntax, where possible #3092
Conversation
hpx/hpx/parallel/algorithms/merge.hpp Lines 262 to 294 in 0b2baf1
@hkaiser I think that this PR also can be applied to above codes like: https://github.com/STEllAR-GROUP/hpx/pull/3092/files#diff-f80eb11bc86e0246f9228af312f375e4R345 for consistency and simplicity. |
@taeguk not sure if it makes sense to move the iterators in the capture list of the lambda. Did I misunderstand what you were trying to say? |
…ossible - flyby: removed unneeded captures
0b2baf1
to
cc466cb
Compare
The failing tests are unrelated. |
hpx/config/lambda_capture.hpp
Outdated
#define HPX_CAPTURE_MOVE(var) var = std::move(var) | ||
#else | ||
#define HPX_CAPTURE_FORWARD(var, type) var | ||
#define HPX_CAPTURE_MOVE(var) var |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I don't think this is a good idea in general. We'll introduce inefficiencies when not having the captures or compile errors (if the objects are not copyable in C++11 mode, for example).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh? This improves the picture for C++14 and leaves things unchanged as they are in C++11.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't through all changes. It might lead to those problems. It does improve the picture for C++14 indeed, but leaves C++11 code behind. As said, I'm not sure if it's a good idea. If we need to keep C++11 compatibility, a better option might be to capture via bind
/deferred_call
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improving the picture for C++11 is independent of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's exactly why I'm saying this might not be a good idea. A solution that would work for both would be significantly different, and requires way more boilerplate. What you propose though, is a C++14 only solution (with a C++11 facade, that's not doing anything). I don't think it's bad to have it that way, but I think it should be without that macro that's not giving us any benefit for older compilers, and will lead to problems eventually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I understand. This is completely orthogonal to this PR, though. Things do not change for C++11 based compilation, no matter whether we apply this PR or not. But things improve for C++14 based compilation, so it's worth going ahead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I understand. This is completely orthogonal to this PR, though. Things do not change for C++11 based compilation, no matter whether we apply this PR or not.
Right, which I think is a potential problem ...
But things improve for C++14 based compilation, so it's worth going ahead.
... as only C++14 code improves. there isn't any problem in particular right now. The problem is the code that will be written against those interfaces. We won't notice any problem since all our compilers actually support lambda init captures. There is no gain in artificially introducing this distinction, that's my main problem. We either solve the problem for all supported flavors of c++ properly (which I strongly support by bumping the requirements) or we keep it as it is to avoid future problems with the two incompatible code paths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sithhell so you're refusing to accept an improvement for 80% of the systems we're running on for the sake of a potential problem which might accidentally be introduced by some careless change on 20% of the systems?
What alternative solution do you suggest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I'm suggesting is to leave the 20% behind properly, by removing support for them and bump the minimal version to C++11 with C++14 lambda init captures. This way, we ensure that no such careless change sneaks in. Besides, problems will most likely manifest in user code first where we don't have any control.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would currently leave behind all of CUDA. I think that's not what we want.
@hkaiser I didn't say about iterators like |
@taeguk: it's almost funny that you're proposing the exact opposite of what @sithhell would like to see. You would like to get rid of All what I propose for now is to improve the existing lambdas for modern compilers. We can move the existing For your other suggestion: would you mind creating a patch demonstrating what you have in mind, please? |
Okay, I agree. I think I was wrong. Now I think just leaving it as it is is better. We can move the existing bind()'s to C++14 lambdas later. I think that we will search not only
Now there is no need to make patch because my opinion is changed like above. |
Bumping the requirements or fixing it properly such that the remaining 20%
aren't left behind.
What are the 20% that don't support init captures?
|
@sithhell approved these changes: http://irclog.cct.lsu.edu/ste~b~~b~ar/2018-01-05#93869; |
Proposed Changes