-
Notifications
You must be signed in to change notification settings - Fork 70
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
Fixes to futures #505
Fixes to futures #505
Conversation
Fixed unnecessary copies of copyable result types when futures are used as rvalues. Propagating exceptions for move-only types are now scheduled on the executor (I'm not sure why they were not scheduled before). Added `copy()` algorithm to utility.hpp to explicitly copy objects.
stlab/utility.hpp
Outdated
/// Returns a copy of the argument. Used to pass an lvalue to function taking an rvalue or to | ||
/// copy a type with an `explicit` copy-constructor. | ||
template <typename T> | ||
T copy(const T& a) { |
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.
Previously you gave an implementation of copy
to be:
template <typename T>
constexpr std::decay_t<T> copy(T&& value) noexcept(
noexcept(std::decay_t<T>{static_cast<T&&>(value)})) {
static_assert(!std::is_same<std::decay_t<T>, T>::value, "explicit copy of rvalue.");
return std::decay_t<T>{static_cast<T&&>(value)};
}
What's changed between now and then that's resulted in the greatly simplified variant?
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.
Moving to use the above - nothing changed other than my memory of writing the above...
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 had one question about your copy
implementation. Other than that I don't see anything wrong with this PR.
Fixed unnecessary copies of copyable result types when futures are used as rvalues. Propagating exceptions for move-only types are now scheduled on the executor (I'm not sure why they were not scheduled before). Added
copy()
algorithm to utility.hpp to explicitly copy objects. Added docs and tests.