Commit ff54a5b1 authored by tzik's avatar tzik Committed by Commit bot

Support rvalue-reference IgnoreResult in base::Bind impl

When an IgnoreResult is passed as a rvalue-reference, Bind impl has passed
the target functor as a lvalue-reference. That causes a compile failure
when the target functor can be run via rvalue-reference only.
This CL changes IgnoreResult handling in base::Bind impl, so that it
uses rvalue-reference functor when IgnoreResult itself is passed as
a rvalue-reference.

BUG=554299

Review-Url: https://codereview.chromium.org/2298133003
Cr-Commit-Position: refs/heads/master@{#415613}
parent 06c696c2
......@@ -244,8 +244,9 @@ struct FunctorTraits<IgnoreResultHelper<T>> : FunctorTraits<T> {
template <typename IgnoreResultType, typename... RunArgs>
static void Invoke(IgnoreResultType&& ignore_result_helper,
RunArgs&&... args) {
FunctorTraits<T>::Invoke(ignore_result_helper.functor_,
std::forward<RunArgs>(args)...);
FunctorTraits<T>::Invoke(
std::forward<IgnoreResultType>(ignore_result_helper).functor_,
std::forward<RunArgs>(args)...);
}
};
......@@ -380,7 +381,7 @@ struct BindState final : BindStateBase {
template <typename ForwardFunctor, typename... ForwardBoundArgs>
explicit BindState(ForwardFunctor&& functor, ForwardBoundArgs&&... bound_args)
: BindStateBase(&Destroy),
functor_(std::forward<ForwardFunctor>(functor)),
functor_(std::forward<ForwardFunctor>(functor)),
bound_args_(std::forward<ForwardBoundArgs>(bound_args)...) {
DCHECK(!IsNull(functor_));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment