You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cppref states that the move constructor and move assignment operator of packaged_task are noexcept, so I think there should be a noexcept specifier here.
Explicitly spell the noexcept-specifier of the move constructor and move assignment operator of packaged_task
heckerpowered
changed the title
Add noexcept specifier to move constructor and move assignment operator
Explicitly spell the noexcept-specifier of the move constructor and move assignment operator of packaged_task
Sep 6, 2024
The reason will be displayed to describe this comment to others. Learn more.
Oops, the original explicit noexcept-specifiers were dropped by #3315... by me.
I used to think that implicit exception specification should be sufficient and would slightly speed up compilation, but I ignored the drawback that it would be harder for users to confirm and rely on the fact that these move functions are always noexcept.
Oops, the original explicit noexcept-specifiers were dropped by #3315... by me.
It's not all on you: in the past we've avoided explicit noexcepts - and even some constexprs - on defaulted member functions. I think it was just to have less code to read, both for us and (as you suggest) the compiler.
I agree that we should be explicit given the enormous number of readers the code gets with a diversity of experiences. It would be nice not to have to read the entire header simply to determine that packaged_task's move constructor is noexcept, or example.
@heckerpowered, for future reference we prefer that authors don't force push PR branches after review starts because it tends to break incremental code review. (GitHub's "show changes since your last review" feature gets confused. Or at least it did, I haven't checked for a while.) It's obviously a non-issue for this two-line change, but for bigger things we will cry and gnash our teeth with frustration. And nobody likes gnashing.
I remembered to check for R& and void specializations (as seen in other <future> technology) but packaged_task doesn't have them, so this change is correct and complete. πΈ
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://en.cppreference.com/w/cpp/thread/packaged_task/packaged_task
https://en.cppreference.com/w/cpp/thread/packaged_task/operator%3D
Cppref states that the move constructor and move assignment operator of packaged_task are noexcept, so I think there should be a noexcept specifier here.