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}
diff --git a/base/bind_internal.h b/base/bind_internal.h
index 3d6ca09c..83e000d 100644
--- a/base/bind_internal.h
+++ b/base/bind_internal.h
@@ -244,8 +244,9 @@
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 @@
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_));
}