The modifications remove unnecessary uses of std::move() for improve… #421
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.
This pull request addresses two modifications in the
promise_impl
class within theexperimental/impl/promise.hpp
file:that there is indeed an unnecessary use of std::move() in the apply_impl function. Specifically, the line f(std::get(std::move(result_type))...); could be modified to remove the unnecessary std::move().
Here's the corrected version of the apply_impl function:
template<typename Func, std::size_t... Idx>
void apply_impl(Func f, boost::asio::detail::index_sequence<Idx...>)
{
auto& result_type = reinterpret_cast<promise_impl::result_type>(&result);
f(std::get(result_type)...); // Remove std::move()
}
and In the operator() function of the promise_handler class, the modification involves removing the unnecessary use of std::move() when storing the result values in the promise object. The line new (&impl_->result) result_type(ts...); initializes the result object by directly forwarding the ts arguments without using std::move().
This modification ensures that the result values are efficiently stored in the promise object without unnecessary moves.
Certainly! Here's an explanation of the modifications made to the code:
**void operator()(std::remove_reference_t... ts)
{
assert(impl_);
using result_type = typename promise_impl<
void(Ts...), allocator_type, executor_type>::result_type ;
new (&impl_->result) result_type(ts...); // Remove std::move()
impl_->done = true;
if (impl_->completion)
impl_->complete_with_result();
}**