Index: base/bind.h |
diff --git a/base/bind.h b/base/bind.h |
index 50b941e45992b145dde1b45e9718c47b3d9956f4..86f624e49c80ae376112a73f88ef007e44d7342c 100644 |
--- a/base/bind.h |
+++ b/base/bind.h |
@@ -31,11 +31,19 @@ inline base::Callback<MakeUnboundRunType<Functor, Args...>> Bind( |
using BindState = internal::MakeBindStateType<Functor, Args...>; |
using UnboundRunType = MakeUnboundRunType<Functor, Args...>; |
using Invoker = internal::Invoker<BindState, UnboundRunType>; |
- |
using CallbackType = Callback<UnboundRunType>; |
- return CallbackType(new BindState(std::forward<Functor>(functor), |
- std::forward<Args>(args)...), |
- &Invoker::Run); |
+ |
+ // Store the invoke func into PolymorphicInvoke before casting it to |
+ // InvokeFuncStorage, so that we can ensure its type matches to |
+ // PolymorphicInvoke, to which CallbackType will cast back. |
+ using PolymorphicInvoke = typename CallbackType::PolymorphicInvoke; |
+ PolymorphicInvoke invoke_func = &Invoker::Run; |
+ |
+ using InvokeFuncStorage = internal::BindStateBase::InvokeFuncStorage; |
+ return CallbackType(new BindState( |
+ reinterpret_cast<InvokeFuncStorage>(invoke_func), |
+ std::forward<Functor>(functor), |
+ std::forward<Args>(args)...)); |
} |
} // namespace base |