| Index: base/bind_internal.h
|
| diff --git a/base/bind_internal.h b/base/bind_internal.h
|
| index c6832e6a479ed3da0a386855327de207e6fedca6..65563fa94ab69557bf5a8daa340bfe22276ee139 100644
|
| --- a/base/bind_internal.h
|
| +++ b/base/bind_internal.h
|
| @@ -108,7 +108,8 @@ template <bool is_method, typename... Args>
|
| struct BindsArrayToFirstArg : false_type {};
|
|
|
| template <typename T, typename... Args>
|
| -struct BindsArrayToFirstArg<true, T, Args...> : is_array<T> {};
|
| +struct BindsArrayToFirstArg<true, T, Args...>
|
| + : is_array<typename std::remove_reference<T>::type> {};
|
|
|
| // HasRefCountedParamAsRawPtr is the same to HasRefCountedTypeAsRawPtr except
|
| // when |is_method| is true HasRefCountedParamAsRawPtr skips the first argument.
|
| @@ -155,8 +156,9 @@ class RunnableAdapter<R(*)(Args...)> {
|
| : function_(function) {
|
| }
|
|
|
| - R Run(typename CallbackParamTraits<Args>::ForwardType... args) {
|
| - return function_(CallbackForward(args)...);
|
| + template <typename... RunArgs>
|
| + R Run(RunArgs&&... args) {
|
| + return function_(std::forward<RunArgs>(args)...);
|
| }
|
|
|
| private:
|
| @@ -174,8 +176,9 @@ class RunnableAdapter<R(T::*)(Args...)> {
|
| : method_(method) {
|
| }
|
|
|
| - R Run(T* object, typename CallbackParamTraits<Args>::ForwardType... args) {
|
| - return (object->*method_)(CallbackForward(args)...);
|
| + template <typename... RunArgs>
|
| + R Run(T* object, RunArgs&&... args) {
|
| + return (object->*method_)(std::forward<RunArgs>(args)...);
|
| }
|
|
|
| private:
|
| @@ -193,9 +196,10 @@ class RunnableAdapter<R(T::*)(Args...) const> {
|
| : method_(method) {
|
| }
|
|
|
| + template <typename... RunArgs>
|
| R Run(const T* object,
|
| - typename CallbackParamTraits<Args>::ForwardType... args) {
|
| - return (object->*method_)(CallbackForward(args)...);
|
| + RunArgs&&... args) {
|
| + return (object->*method_)(std::forward<RunArgs>(args)...);
|
| }
|
|
|
| private:
|
| @@ -284,25 +288,30 @@ struct InvokeHelper;
|
|
|
| template <typename ReturnType, typename Runnable, typename... Args>
|
| struct InvokeHelper<false, ReturnType, Runnable, TypeList<Args...>> {
|
| - static ReturnType MakeItSo(Runnable runnable, Args... args) {
|
| - return runnable.Run(CallbackForward(args)...);
|
| + template <typename... RunArgs>
|
| + static ReturnType MakeItSo(Runnable runnable, RunArgs&&... args) {
|
| + return runnable.Run(std::forward<RunArgs>(args)...);
|
| }
|
| };
|
|
|
| template <typename Runnable, typename... Args>
|
| struct InvokeHelper<false, void, Runnable, TypeList<Args...>> {
|
| - static void MakeItSo(Runnable runnable, Args... args) {
|
| - runnable.Run(CallbackForward(args)...);
|
| + template <typename... RunArgs>
|
| + static void MakeItSo(Runnable runnable, RunArgs&&... args) {
|
| + runnable.Run(std::forward<RunArgs>(args)...);
|
| }
|
| };
|
|
|
| template <typename Runnable, typename BoundWeakPtr, typename... Args>
|
| struct InvokeHelper<true, void, Runnable, TypeList<BoundWeakPtr, Args...>> {
|
| - static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, Args... args) {
|
| + template <typename... RunArgs>
|
| + static void MakeItSo(Runnable runnable,
|
| + BoundWeakPtr weak_ptr,
|
| + RunArgs&&... args) {
|
| if (!weak_ptr.get()) {
|
| return;
|
| }
|
| - runnable.Run(weak_ptr.get(), CallbackForward(args)...);
|
| + runnable.Run(weak_ptr.get(), std::forward<RunArgs>(args)...);
|
| }
|
| };
|
|
|
| @@ -337,7 +346,8 @@ struct Invoker<IndexSequence<bound_indices...>,
|
| StorageType, TypeList<Unwrappers...>,
|
| InvokeHelperType, R(UnboundForwardArgs...)> {
|
| static R Run(BindStateBase* base,
|
| - UnboundForwardArgs... unbound_args) {
|
| + typename CallbackParamTraits<
|
| + UnboundForwardArgs>::ForwardType... unbound_args) {
|
| StorageType* storage = static_cast<StorageType*>(base);
|
| // Local references to make debugger stepping easier. If in a debugger,
|
| // you really want to warp ahead and step through the
|
| @@ -345,11 +355,10 @@ struct Invoker<IndexSequence<bound_indices...>,
|
| return InvokeHelperType::MakeItSo(
|
| storage->runnable_,
|
| Unwrappers::Unwrap(get<bound_indices>(storage->bound_args_))...,
|
| - CallbackForward(unbound_args)...);
|
| + CallbackForward2(unbound_args)...);
|
| }
|
| };
|
|
|
| -
|
| // BindState<>
|
| //
|
| // This stores all the state passed into Bind() and is also where most
|
| @@ -382,9 +391,8 @@ struct BindState<Runnable, R(Args...), TypeList<BoundArgs...>> final
|
|
|
| using BoundIndices = MakeIndexSequence<sizeof...(BoundArgs)>;
|
| using Unwrappers = TypeList<UnwrapTraits<BoundArgs>...>;
|
| - using UnboundForwardArgs = DropTypeListItem<
|
| - sizeof...(BoundArgs),
|
| - TypeList<typename CallbackParamTraits<Args>::ForwardType...>>;
|
| + using UnboundForwardArgs =
|
| + DropTypeListItem<sizeof...(BoundArgs), TypeList<Args...>>;
|
| using UnboundForwardRunType = MakeFunctionType<R, UnboundForwardArgs>;
|
|
|
| using InvokeHelperArgs = ConcatTypeLists<
|
| @@ -400,15 +408,16 @@ struct BindState<Runnable, R(Args...), TypeList<BoundArgs...>> final
|
| InvokeHelperType, UnboundForwardRunType>;
|
| using UnboundRunType = MakeFunctionType<R, UnboundArgs>;
|
|
|
| - BindState(const Runnable& runnable, const BoundArgs&... bound_args)
|
| + template <typename... PassedBoundArgs>
|
| + BindState(const Runnable& runnable, PassedBoundArgs&&... bound_args)
|
| : BindStateBase(&Destroy),
|
| runnable_(runnable),
|
| ref_(bound_args...),
|
| - bound_args_(bound_args...) {}
|
| + bound_args_(std::forward<PassedBoundArgs>(bound_args)...) {}
|
|
|
| RunnableType runnable_;
|
| MaybeScopedRefPtr<HasIsMethodTag<Runnable>::value, BoundArgs...> ref_;
|
| - Tuple<BoundArgs...> bound_args_;
|
| + std::tuple<BoundArgs...> bound_args_;
|
|
|
| private:
|
| ~BindState() {}
|
|
|