Chromium Code Reviews| Index: base/bind_helpers.h |
| diff --git a/base/bind_helpers.h b/base/bind_helpers.h |
| index d86393bec05676d942bd13f3df72a08ce828d53a..093f5dcfeeead6af87659347517a398472eb3cf3 100644 |
| --- a/base/bind_helpers.h |
| +++ b/base/bind_helpers.h |
| @@ -344,18 +344,11 @@ class RetainedRefWrapper { |
| template <typename T> |
| struct IgnoreResultHelper { |
| - explicit IgnoreResultHelper(T functor) : functor_(functor) {} |
| + explicit IgnoreResultHelper(T functor) : functor_(std::move(functor)) {} |
|
Yuta Kitamura
2016/06/29 00:07:55
Do you expect |T| to be something like Callback<T>
tzik
2016/06/29 02:49:08
T is a Functor. That can be Callback<>, function p
|
| T functor_; |
| }; |
| -template <typename T> |
| -struct IgnoreResultHelper<Callback<T> > { |
| - explicit IgnoreResultHelper(const Callback<T>& functor) : functor_(functor) {} |
| - |
| - const Callback<T>& functor_; |
| -}; |
| - |
| // An alternate implementation is to avoid the destructive copy, and instead |
| // specialize ParamTraits<> for OwnedWrapper<> to change the StorageType to |
| // a class that is essentially a std::unique_ptr<>. |
| @@ -421,8 +414,8 @@ class PassedWrapper { |
| // Unwrap the stored parameters for the wrappers above. |
| template <typename T> |
| -const T& Unwrap(const T& o) { |
| - return o; |
| +T&& Unwrap(T&& o) { |
|
Yuta Kitamura
2016/06/29 00:07:55
aside: If the argument can be an rvalue reference,
tzik
2016/06/29 02:49:08
No. The constness of the internal storage is from
|
| + return std::forward<T>(o); |
| } |
| template <typename T> |
| @@ -611,13 +604,7 @@ static inline internal::PassedWrapper<T> Passed(T* scoper) { |
| template <typename T> |
| static inline internal::IgnoreResultHelper<T> IgnoreResult(T data) { |
| - return internal::IgnoreResultHelper<T>(data); |
| -} |
| - |
| -template <typename T> |
| -static inline internal::IgnoreResultHelper<Callback<T> > |
| -IgnoreResult(const Callback<T>& data) { |
| - return internal::IgnoreResultHelper<Callback<T> >(data); |
| + return internal::IgnoreResultHelper<T>(std::move(data)); |
| } |
| BASE_EXPORT void DoNothing(); |