Skip to content
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

The modifications remove unnecessary uses of std::move() for improve… #421

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions include/boost/asio/experimental/impl/promise.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,14 @@ struct promise_impl<void(Ts...), Executor, Allocator>
Allocator allocator;
Executor executor;

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<Idx>(std::move(result_type))...);
}
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<Idx>(result_type)...); // Remove std::move()
}



using allocator_type = Allocator;
allocator_type get_allocator() {return allocator;}
Expand Down Expand Up @@ -231,19 +233,20 @@ struct promise_handler<void(Ts...), Executor, Allocator>
return promise<void(Ts...), executor_type, allocator_type>{impl_};
}

void operator()(std::remove_reference_t<Ts>... ts)
{
assert(impl_);
void operator()(std::remove_reference_t<Ts>... ts)
{
assert(impl_);

using result_type = typename promise_impl<
void(Ts...), allocator_type, executor_type>::result_type ;
using result_type = typename promise_impl<
void(Ts...), allocator_type, executor_type>::result_type ;

new (&impl_->result) result_type(std::move(ts)...);
impl_->done = true;
new (&impl_->result) result_type(ts...); // Remove std::move()

if (impl_->completion)
impl_->complete_with_result();
}
impl_->done = true;

if (impl_->completion)
impl_->complete_with_result();
}
};

} // namespace detail
Expand Down