Index: base/bind_internal.h.pump |
diff --git a/base/bind_internal.h.pump b/base/bind_internal.h.pump |
index f632b99e556db0aeb1669dabd1dc1b4b1be30e97..9ddca4758c56ab6aebf742504db3725cd7ef4e9b 100644 |
--- a/base/bind_internal.h.pump |
+++ b/base/bind_internal.h.pump |
@@ -57,18 +57,15 @@ namespace internal { |
// Types: |
// RunnableAdapter<> -- Wraps the various "function" pointer types into an |
// object that adheres to the Runnable interface. |
-// There are |3*ARITY| RunnableAdapter types. |
// FunctionTraits<> -- Type traits that unwrap a function signature into a |
// a set of easier to use typedefs. Used mainly for |
// compile time asserts. |
// There are |ARITY| FunctionTraits types. |
// ForceVoidReturn<> -- Helper class for translating function signatures to |
// equivalent forms with a "void" return type. |
-// There are |ARITY| ForceVoidReturn types. |
// FunctorTraits<> -- Type traits used determine the correct RunType and |
// RunnableType for a Functor. This is where function |
// signature adapters are applied. |
-// There are |ARITY| ForceVoidReturn types. |
// MakeRunnable<> -- Takes a Functor and returns an object in the Runnable |
// type class that represents the underlying Functor. |
// There are |O(1)| MakeRunnable types. |
@@ -77,7 +74,6 @@ namespace internal { |
// and for ignoring return values. This is separate from |
// Invoker to avoid creating multiple version of Invoker<> |
// which grows at O(n^2) with the arity. |
-// There are |k*ARITY| InvokeHelper types. |
// Invoker<> -- Unwraps the curried parameters and executes the Runnable. |
// There are |(ARITY^2 + ARITY)/2| Invoketypes. |
// BindState<> -- Stores the curried parameters, and is the main entry point |
@@ -107,75 +103,64 @@ namespace internal { |
template <typename Functor> |
class RunnableAdapter; |
-$for ARITY [[ |
-$range ARG 1..ARITY |
- |
-// Function: Arity $(ARITY). |
-template <typename R[[]] |
-$if ARITY > 0[[, ]] $for ARG , [[typename A$(ARG)]]> |
-class RunnableAdapter<R(*)($for ARG , [[A$(ARG)]])> { |
+// Function. |
+template <typename R, typename... Args> |
+class RunnableAdapter<R(*)(Args...)> { |
public: |
- typedef R (RunType)($for ARG , [[A$(ARG)]]); |
+ typedef R (RunType)(Args...); |
- explicit RunnableAdapter(R(*function)($for ARG , [[A$(ARG)]])) |
+ explicit RunnableAdapter(R(*function)(Args...)) |
: function_(function) { |
} |
- R Run($for ARG , [[typename CallbackParamTraits<A$(ARG)>::ForwardType a$(ARG)]]) { |
- return function_($for ARG , [[CallbackForward(a$(ARG))]]); |
+ R Run(typename CallbackParamTraits<Args>::ForwardType... args) { |
+ return function_(CallbackForward(args)...); |
} |
private: |
- R (*function_)($for ARG , [[A$(ARG)]]); |
+ R (*function_)(Args...); |
}; |
-// Method: Arity $(ARITY). |
-template <typename R, typename T[[]] |
-$if ARITY > 0[[, ]] $for ARG , [[typename A$(ARG)]]> |
-class RunnableAdapter<R(T::*)($for ARG , [[A$(ARG)]])> { |
+// Method. |
+template <typename R, typename T, typename... Args> |
+class RunnableAdapter<R(T::*)(Args...)> { |
public: |
- typedef R (RunType)(T*[[]] |
-$if ARITY > 0[[, ]] $for ARG , [[A$(ARG)]]); |
+ typedef R (RunType)(T*, Args...); |
typedef true_type IsMethod; |
- explicit RunnableAdapter(R(T::*method)($for ARG , [[A$(ARG)]])) |
+ explicit RunnableAdapter(R(T::*method)(Args...)) |
: method_(method) { |
} |
- R Run(T* object[[]] |
-$if ARITY > 0[[, ]] $for ARG, [[typename CallbackParamTraits<A$(ARG)>::ForwardType a$(ARG)]]) { |
- return (object->*method_)($for ARG , [[CallbackForward(a$(ARG))]]); |
+ R Run(T* object, typename CallbackParamTraits<Args>::ForwardType... args) { |
+ return (object->*method_)(CallbackForward(args)...); |
} |
private: |
- R (T::*method_)($for ARG , [[A$(ARG)]]); |
+ R (T::*method_)(Args...); |
}; |
-// Const Method: Arity $(ARITY). |
-template <typename R, typename T[[]] |
-$if ARITY > 0[[, ]] $for ARG , [[typename A$(ARG)]]> |
-class RunnableAdapter<R(T::*)($for ARG , [[A$(ARG)]]) const> { |
+// Const Method. |
+template <typename R, typename T, typename... Args> |
+class RunnableAdapter<R(T::*)(Args...) const> { |
public: |
- typedef R (RunType)(const T*[[]] |
-$if ARITY > 0[[, ]] $for ARG , [[A$(ARG)]]); |
+ typedef R (RunType)(const T*, Args...); |
typedef true_type IsMethod; |
- explicit RunnableAdapter(R(T::*method)($for ARG , [[A$(ARG)]]) const) |
+ explicit RunnableAdapter(R(T::*method)(Args...) const) |
: method_(method) { |
} |
- R Run(const T* object[[]] |
-$if ARITY > 0[[, ]] $for ARG, [[typename CallbackParamTraits<A$(ARG)>::ForwardType a$(ARG)]]) { |
- return (object->*method_)($for ARG , [[CallbackForward(a$(ARG))]]); |
+ R Run(const T* object, |
+ typename CallbackParamTraits<Args>::ForwardType... args) { |
+ return (object->*method_)(CallbackForward(args)...); |
} |
private: |
- R (T::*method_)($for ARG , [[A$(ARG)]]) const; |
+ R (T::*method_)(Args...) const; |
}; |
-]] $$ for ARITY |
- |
- |
+// TODO(tzik): Remove FunctionTraits after we finish removing bind.pump. |
// FunctionTraits<> |
// |
// Breaks a function signature apart into typedefs for easier introspection. |
@@ -205,17 +190,11 @@ $for ARG [[ |
template <typename Sig> |
struct ForceVoidReturn; |
-$for ARITY [[ |
-$range ARG 1..ARITY |
- |
-template <typename R[[]] |
-$if ARITY > 0[[, ]] $for ARG , [[typename A$(ARG)]]> |
-struct ForceVoidReturn<R($for ARG , [[A$(ARG)]])> { |
- typedef void(RunType)($for ARG , [[A$(ARG)]]); |
+template <typename R, typename... Args> |
+struct ForceVoidReturn<R(Args...)> { |
+ typedef void(RunType)(Args...); |
}; |
-]] $$ for ARITY |
- |
// FunctorTraits<> |
// |
@@ -284,51 +263,31 @@ template <bool IsWeakCall, typename ReturnType, typename Runnable, |
typename ArgsType> |
struct InvokeHelper; |
-$for ARITY [[ |
-$range ARG 1..ARITY |
-$range WEAKCALL_ARG 2..ARITY |
- |
-template <typename ReturnType, typename Runnable[[]] |
-$if ARITY > 0 [[,]] $for ARG , [[typename A$(ARG)]]> |
+template <typename ReturnType, typename Runnable, typename... Args> |
struct InvokeHelper<false, ReturnType, Runnable, |
- void($for ARG , [[A$(ARG)]])> { |
- static ReturnType MakeItSo(Runnable runnable[[]] |
-$if ARITY > 0[[, ]] $for ARG , [[A$(ARG) a$(ARG)]]) { |
- return runnable.Run($for ARG , [[CallbackForward(a$(ARG))]]); |
+ void(Args...)> { |
+ static ReturnType MakeItSo(Runnable runnable, Args... args) { |
+ return runnable.Run(CallbackForward(args)...); |
} |
}; |
-template <typename Runnable[[]] |
-$if ARITY > 0 [[,]] $for ARG , [[typename A$(ARG)]]> |
-struct InvokeHelper<false, void, Runnable, |
- void($for ARG , [[A$(ARG)]])> { |
- static void MakeItSo(Runnable runnable[[]] |
-$if ARITY > 0[[, ]] $for ARG , [[A$(ARG) a$(ARG)]]) { |
- runnable.Run($for ARG , [[CallbackForward(a$(ARG))]]); |
+template <typename Runnable, typename... Args> |
+struct InvokeHelper<false, void, Runnable, void(Args...)> { |
+ static void MakeItSo(Runnable runnable, Args... args) { |
+ runnable.Run(CallbackForward(args)...); |
} |
}; |
-$if ARITY > 0 [[ |
- |
-template <typename Runnable[[]], typename BoundWeakPtr |
-$if ARITY > 1[[, ]] $for WEAKCALL_ARG , [[typename A$(WEAKCALL_ARG)]]> |
-struct InvokeHelper<true, void, Runnable, |
- void(BoundWeakPtr |
-$if ARITY > 1[[, ]] $for WEAKCALL_ARG , [[A$(WEAKCALL_ARG)]])> { |
- static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr |
-$if ARITY > 1[[, ]] $for WEAKCALL_ARG , [[A$(WEAKCALL_ARG) a$(WEAKCALL_ARG)]]) { |
+template <typename Runnable, typename BoundWeakPtr, typename... Args> |
+struct InvokeHelper<true, void, Runnable, void(BoundWeakPtr, Args...)> { |
+ static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, Args... args) { |
if (!weak_ptr.get()) { |
return; |
} |
- runnable.Run(weak_ptr.get() |
-$if ARITY > 1[[, ]] $for WEAKCALL_ARG , [[CallbackForward(a$(WEAKCALL_ARG))]]); |
+ runnable.Run(weak_ptr.get(), CallbackForward(args)...); |
} |
}; |
-]] |
- |
-]] $$ for ARITY |
- |
#if !defined(_MSC_VER) |
template <typename ReturnType, typename Runnable, typename ArgsType> |