Decouple Invoker from BindState
Move most of type-level logic out of BindState, and decouple Invoker
from BindState. So that we can use BindState with another Invoker impl.
- UnboundRunType calculation is moved to a separate helper template as
MakeUnboundRuntype.
- Indices generation to extract tuple is moved from BindState to
Invoker.
- WeakPtr handling is moved from BindState to Invoker.
This is a preparation CL as well to implement a OneShot variant of
Callback. That will share the same Callback and BindState impl with
different Invoker::Run impl and different Callback tag as Copyable
Callback and MoveOnly Callback have.
BUG=554299
Review-Url: https://codereview.chromium.org/2034633002
Cr-Commit-Position: refs/heads/master@{#402446}
CrOS-Libchrome-Original-Commit: caf1d84bb83aaf5369eb508027a685e2bf9859b4
diff --git a/base/bind_helpers.h b/base/bind_helpers.h
index fe4e908..3683902 100644
--- a/base/bind_helpers.h
+++ b/base/bind_helpers.h
@@ -462,7 +462,7 @@
//
// The first argument should be the type of the object that will be received by
// the method.
-template <bool IsMethod, typename... Args>
+template <bool is_method, typename... Args>
struct IsWeakMethod : std::false_type {};
template <typename T, typename... Args>
@@ -549,19 +549,25 @@
template <typename R, typename ArgList>
using MakeFunctionType = typename MakeFunctionTypeImpl<R, ArgList>::Type;
-// Used for ExtractArgs.
+// Used for ExtractArgs and ExtractReturnType.
template <typename Signature>
struct ExtractArgsImpl;
template <typename R, typename... Args>
struct ExtractArgsImpl<R(Args...)> {
- using Type = TypeList<Args...>;
+ using ReturnType = R;
+ using ArgsList = TypeList<Args...>;
};
// A type-level function that extracts function arguments into a TypeList.
// E.g. ExtractArgs<R(A, B, C)> is evaluated to TypeList<A, B, C>.
template <typename Signature>
-using ExtractArgs = typename ExtractArgsImpl<Signature>::Type;
+using ExtractArgs = typename ExtractArgsImpl<Signature>::ArgsList;
+
+// A type-level function that extracts the return type of a function.
+// E.g. ExtractReturnType<R(A, B, C)> is evaluated to R.
+template <typename Signature>
+using ExtractReturnType = typename ExtractArgsImpl<Signature>::ReturnType;
} // namespace internal