-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Explicitly spell the noexcept-specifier of the move constructor and move assignment operator of packaged_task #4940
Conversation
This PR seems to be an improvement as it makes However, the touched move functions are already implicitly #include <future>
#include <type_traits>
static_assert(std::is_nothrow_move_constructible_v<std::packaged_task<void()>>);
static_assert(std::is_nothrow_move_constructible_v<std::packaged_task<int(long)>>);
static_assert(std::is_nothrow_move_assignable_v<std::packaged_task<void()>>);
static_assert(std::is_nothrow_move_assignable_v<std::packaged_task<int(long)>>); I think the title of this PR should be changed to
|
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.
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
.
@microsoft-github-policy-service agree |
It's not all on you: in the past we've avoided explicit 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 |
@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 |
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
Thanks for this clarity improvement and congratulations on your first microsoft/STL commit! 🎉 😸 🚀 |
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.