blob: e3ccb25d5ecbe9b9aa6635df309826c9a31f7b60 [file] [log] [blame]
ajwong@chromium.orge2cca632011-02-15 10:27:38 +09001// Copyright (c) 2011 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef BASE_BIND_INTERNAL_H_
6#define BASE_BIND_INTERNAL_H_
ajwong@chromium.orge2cca632011-02-15 10:27:38 +09007
avia6a6a682015-12-27 07:15:14 +09008#include <stddef.h>
9
tzikf09a3702016-06-03 16:25:20 +090010#include <tuple>
vmpstr495da402015-11-18 17:43:26 +090011#include <type_traits>
12
ajwong@chromium.orge2cca632011-02-15 10:27:38 +090013#include "base/bind_helpers.h"
ajwong@chromium.orgfa0ff432011-02-19 08:29:31 +090014#include "base/callback_internal.h"
ajwong@chromium.org27e56852011-10-01 15:31:41 +090015#include "base/memory/raw_scoped_refptr_mismatch_checker.h"
ajwong@chromium.orgc711b822011-05-17 07:35:14 +090016#include "base/memory/weak_ptr.h"
ajwong@chromium.orge2cca632011-02-15 10:27:38 +090017#include "base/template_util.h"
tzik07e99402015-02-06 04:11:26 +090018#include "base/tuple.h"
ajwong@chromium.orgcb175342011-02-27 10:25:59 +090019#include "build/build_config.h"
20
ajwong@chromium.orge2cca632011-02-15 10:27:38 +090021namespace base {
22namespace internal {
23
brettw@chromium.org11e3bfd2012-07-13 05:06:40 +090024// See base/callback.h for user documentation.
25//
26//
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +090027// CONCEPTS:
tzik9f27e1f2016-07-01 14:54:12 +090028// Functor -- A movable type representing something that should be called.
29// All function pointers and Callback<> are functors even if the
30// invocation syntax differs.
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +090031// RunType -- A function type (as opposed to function _pointer_ type) for
tzik9f27e1f2016-07-01 14:54:12 +090032// a Callback<>::Run(). Usually just a convenience typedef.
tzikb0632222015-12-15 15:41:49 +090033// (Bound)Args -- A set of types that stores the arguments.
ajwong@chromium.orge2cca632011-02-15 10:27:38 +090034//
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +090035// Types:
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +090036// ForceVoidReturn<> -- Helper class for translating function signatures to
37// equivalent forms with a "void" return type.
tzik9f27e1f2016-07-01 14:54:12 +090038// FunctorTraits<> -- Type traits used to determine the correct RunType and
39// invocation manner for a Functor. This is where function
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +090040// signature adapters are applied.
tzik9f27e1f2016-07-01 14:54:12 +090041// InvokeHelper<> -- Take a Functor + arguments and actully invokes it.
tzik07e99402015-02-06 04:11:26 +090042// Handle the differing syntaxes needed for WeakPtr<>
tzik9f27e1f2016-07-01 14:54:12 +090043// support. This is separate from Invoker to avoid creating
44// multiple version of Invoker<>.
45// Invoker<> -- Unwraps the curried parameters and executes the Functor.
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +090046// BindState<> -- Stores the curried parameters, and is the main entry point
tzik9f27e1f2016-07-01 14:54:12 +090047// into the Bind() system.
ajwong@chromium.orge0648232011-02-19 09:52:15 +090048
tzik31d3fae2016-07-08 18:42:38 +090049template <typename...>
50struct make_void {
51 using type = void;
52};
53
54// A clone of C++17 std::void_t.
55// Unlike the original version, we need |make_void| as a helper struct to avoid
56// a C++14 defect.
57// ref: http://en.cppreference.com/w/cpp/types/void_t
58// ref: http://open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#1558
59template <typename... Ts>
60using void_t = typename make_void<Ts...>::type;
61
62template <typename Callable,
63 typename Signature = decltype(&Callable::operator())>
64struct ExtractCallableRunTypeImpl;
65
66template <typename Callable, typename R, typename... Args>
67struct ExtractCallableRunTypeImpl<Callable, R(Callable::*)(Args...) const> {
68 using Type = R(Args...);
69};
70
71// Evaluated to RunType of the given callable type.
72// Example:
73// auto f = [](int, char*) { return 0.1; };
74// ExtractCallableRunType<decltype(f)>
75// is evaluated to
76// double(int, char*);
77template <typename Callable>
78using ExtractCallableRunType =
79 typename ExtractCallableRunTypeImpl<Callable>::Type;
80
81// IsConvertibleToRunType<Functor> is std::true_type if |Functor| has operator()
82// and convertible to the corresponding function pointer. Otherwise, it's
83// std::false_type.
84// Example:
85// IsConvertibleToRunType<void(*)()>::value is false.
86//
87// struct Foo {};
88// IsConvertibleToRunType<void(Foo::*)()>::value is false.
89//
90// auto f = []() {};
91// IsConvertibleToRunType<decltype(f)>::value is true.
92//
93// int i = 0;
94// auto g = [i]() {};
95// IsConvertibleToRunType<decltype(g)>::value is false.
96template <typename Functor, typename SFINAE = void>
97struct IsConvertibleToRunType : std::false_type {};
98
99template <typename Callable>
100struct IsConvertibleToRunType<Callable, void_t<decltype(&Callable::operator())>>
101 : std::is_convertible<Callable, ExtractCallableRunType<Callable>*> {};
102
tzik8df08a52014-11-26 16:54:58 +0900103// HasRefCountedTypeAsRawPtr selects true_type when any of the |Args| is a raw
104// pointer to a RefCounted type.
105// Implementation note: This non-specialized case handles zero-arity case only.
106// Non-zero-arity cases should be handled by the specialization below.
107template <typename... Args>
tzik56bd7652016-03-10 16:17:25 +0900108struct HasRefCountedTypeAsRawPtr : std::false_type {};
tzik8df08a52014-11-26 16:54:58 +0900109
110// Implementation note: Select true_type if the first parameter is a raw pointer
111// to a RefCounted type. Otherwise, skip the first parameter and check rest of
112// parameters recursively.
113template <typename T, typename... Args>
114struct HasRefCountedTypeAsRawPtr<T, Args...>
vmpstr495da402015-11-18 17:43:26 +0900115 : std::conditional<NeedsScopedRefptrButGetsRawPtr<T>::value,
tzik56bd7652016-03-10 16:17:25 +0900116 std::true_type,
vmpstr495da402015-11-18 17:43:26 +0900117 HasRefCountedTypeAsRawPtr<Args...>>::type {};
tzik8df08a52014-11-26 16:54:58 +0900118
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900119// ForceVoidReturn<>
120//
121// Set of templates that support forcing the function return type to void.
122template <typename Sig>
123struct ForceVoidReturn;
124
tzik012481a2014-11-20 19:09:45 +0900125template <typename R, typename... Args>
126struct ForceVoidReturn<R(Args...)> {
tzik9f27e1f2016-07-01 14:54:12 +0900127 using RunType = void(Args...);
ajwong@chromium.org6f015bd2011-11-29 07:13:54 +0900128};
129
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900130// FunctorTraits<>
131//
132// See description at top of file.
tzik31d3fae2016-07-08 18:42:38 +0900133template <typename Functor, typename SFINAE = void>
tzik9f27e1f2016-07-01 14:54:12 +0900134struct FunctorTraits;
135
tzik31d3fae2016-07-08 18:42:38 +0900136// For a callable type that is convertible to the corresponding function type.
137// This specialization is intended to allow binding captureless lambdas by
138// base::Bind(), based on the fact that captureless lambdas can be convertible
139// to the function type while capturing lambdas can't.
140template <typename Functor>
141struct FunctorTraits<
142 Functor,
143 typename std::enable_if<IsConvertibleToRunType<Functor>::value>::type> {
144 using RunType = ExtractCallableRunType<Functor>;
145 static constexpr bool is_method = false;
146 static constexpr bool is_nullable = false;
147
148 template <typename... RunArgs>
149 static ExtractReturnType<RunType>
150 Invoke(const Functor& functor, RunArgs&&... args) {
151 return functor(std::forward<RunArgs>(args)...);
152 }
153};
154
tzik9f27e1f2016-07-01 14:54:12 +0900155// For functions.
156template <typename R, typename... Args>
157struct FunctorTraits<R (*)(Args...)> {
158 using RunType = R(Args...);
159 static constexpr bool is_method = false;
tzik31d3fae2016-07-08 18:42:38 +0900160 static constexpr bool is_nullable = true;
tzik9f27e1f2016-07-01 14:54:12 +0900161
162 template <typename... RunArgs>
163 static R Invoke(R (*function)(Args...), RunArgs&&... args) {
164 return function(std::forward<RunArgs>(args)...);
165 }
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900166};
167
tzik9f27e1f2016-07-01 14:54:12 +0900168#if defined(OS_WIN) && !defined(ARCH_CPU_X86_64)
169
170// For functions.
171template <typename R, typename... Args>
172struct FunctorTraits<R(__stdcall*)(Args...)> {
173 using RunType = R(Args...);
174 static constexpr bool is_method = false;
tzik31d3fae2016-07-08 18:42:38 +0900175 static constexpr bool is_nullable = true;
tzik9f27e1f2016-07-01 14:54:12 +0900176
177 template <typename... RunArgs>
178 static R Invoke(R(__stdcall* function)(Args...), RunArgs&&... args) {
179 return function(std::forward<RunArgs>(args)...);
180 }
181};
182
183// For functions.
184template <typename R, typename... Args>
185struct FunctorTraits<R(__fastcall*)(Args...)> {
186 using RunType = R(Args...);
187 static constexpr bool is_method = false;
tzik31d3fae2016-07-08 18:42:38 +0900188 static constexpr bool is_nullable = true;
tzik9f27e1f2016-07-01 14:54:12 +0900189
190 template <typename... RunArgs>
191 static R Invoke(R(__fastcall* function)(Args...), RunArgs&&... args) {
192 return function(std::forward<RunArgs>(args)...);
193 }
194};
195
196#endif // defined(OS_WIN) && !defined(ARCH_CPU_X86_64)
197
198// For methods.
199template <typename R, typename Receiver, typename... Args>
200struct FunctorTraits<R (Receiver::*)(Args...)> {
201 using RunType = R(Receiver*, Args...);
202 static constexpr bool is_method = true;
tzik31d3fae2016-07-08 18:42:38 +0900203 static constexpr bool is_nullable = true;
tzik9f27e1f2016-07-01 14:54:12 +0900204
205 template <typename ReceiverPtr, typename... RunArgs>
206 static R Invoke(R (Receiver::*method)(Args...),
207 ReceiverPtr&& receiver_ptr,
208 RunArgs&&... args) {
209 // Clang skips CV qualifier check on a method pointer invocation when the
210 // receiver is a subclass. Store the receiver into a const reference to
211 // T to ensure the CV check works.
212 // https://llvm.org/bugs/show_bug.cgi?id=27037
213 Receiver& receiver = *receiver_ptr;
214 return (receiver.*method)(std::forward<RunArgs>(args)...);
215 }
216};
217
218// For const methods.
219template <typename R, typename Receiver, typename... Args>
220struct FunctorTraits<R (Receiver::*)(Args...) const> {
221 using RunType = R(const Receiver*, Args...);
222 static constexpr bool is_method = true;
tzik31d3fae2016-07-08 18:42:38 +0900223 static constexpr bool is_nullable = true;
tzik9f27e1f2016-07-01 14:54:12 +0900224
225 template <typename ReceiverPtr, typename... RunArgs>
226 static R Invoke(R (Receiver::*method)(Args...) const,
227 ReceiverPtr&& receiver_ptr,
228 RunArgs&&... args) {
229 // Clang skips CV qualifier check on a method pointer invocation when the
230 // receiver is a subclass. Store the receiver into a const reference to
231 // T to ensure the CV check works.
232 // https://llvm.org/bugs/show_bug.cgi?id=27037
233 const Receiver& receiver = *receiver_ptr;
234 return (receiver.*method)(std::forward<RunArgs>(args)...);
235 }
236};
237
238// For IgnoreResults.
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900239template <typename T>
tzik9f27e1f2016-07-01 14:54:12 +0900240struct FunctorTraits<IgnoreResultHelper<T>> : FunctorTraits<T> {
tzik260fab52015-12-19 18:18:46 +0900241 using RunType =
tzik9f27e1f2016-07-01 14:54:12 +0900242 typename ForceVoidReturn<typename FunctorTraits<T>::RunType>::RunType;
243
244 template <typename IgnoreResultType, typename... RunArgs>
245 static void Invoke(IgnoreResultType&& ignore_result_helper,
246 RunArgs&&... args) {
247 FunctorTraits<T>::Invoke(ignore_result_helper.functor_,
248 std::forward<RunArgs>(args)...);
249 }
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900250};
251
tzik9f27e1f2016-07-01 14:54:12 +0900252// For Callbacks.
253template <typename R, typename... Args, CopyMode copy_mode>
254struct FunctorTraits<Callback<R(Args...), copy_mode>> {
255 using RunType = R(Args...);
256 static constexpr bool is_method = false;
tzik31d3fae2016-07-08 18:42:38 +0900257 static constexpr bool is_nullable = true;
tzik9f27e1f2016-07-01 14:54:12 +0900258
259 template <typename CallbackType, typename... RunArgs>
260 static R Invoke(CallbackType&& callback, RunArgs&&... args) {
261 DCHECK(!callback.is_null());
262 return std::forward<CallbackType>(callback).Run(
263 std::forward<RunArgs>(args)...);
264 }
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900265};
266
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900267// InvokeHelper<>
268//
tzik9f27e1f2016-07-01 14:54:12 +0900269// There are 2 logical InvokeHelper<> specializations: normal, WeakCalls.
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900270//
271// The normal type just calls the underlying runnable.
272//
tzik9f27e1f2016-07-01 14:54:12 +0900273// WeakCalls need special syntax that is applied to the first argument to check
274// if they should no-op themselves.
tzike1ad6f62016-06-01 17:22:51 +0900275template <bool is_weak_call, typename ReturnType>
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900276struct InvokeHelper;
277
tzike1ad6f62016-06-01 17:22:51 +0900278template <typename ReturnType>
279struct InvokeHelper<false, ReturnType> {
tzik9f27e1f2016-07-01 14:54:12 +0900280 template <typename Functor, typename... RunArgs>
281 static inline ReturnType MakeItSo(Functor&& functor, RunArgs&&... args) {
282 using Traits = FunctorTraits<typename std::decay<Functor>::type>;
283 return Traits::Invoke(std::forward<Functor>(functor),
284 std::forward<RunArgs>(args)...);
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900285 }
286};
287
tzike1ad6f62016-06-01 17:22:51 +0900288template <typename ReturnType>
289struct InvokeHelper<true, ReturnType> {
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900290 // WeakCalls are only supported for functions with a void return type.
291 // Otherwise, the function result would be undefined if the the WeakPtr<>
292 // is invalidated.
tzik56bd7652016-03-10 16:17:25 +0900293 static_assert(std::is_void<ReturnType>::value,
avi486c61f2015-11-24 23:26:24 +0900294 "weak_ptrs can only bind to methods without return values");
ajwong@chromium.orga7e74822011-03-24 11:02:17 +0900295
tzik9f27e1f2016-07-01 14:54:12 +0900296 template <typename Functor, typename BoundWeakPtr, typename... RunArgs>
297 static inline void MakeItSo(Functor&& functor,
298 BoundWeakPtr weak_ptr,
299 RunArgs&&... args) {
300 if (!weak_ptr)
301 return;
302 using Traits = FunctorTraits<typename std::decay<Functor>::type>;
303 Traits::Invoke(std::forward<Functor>(functor),
304 std::forward<BoundWeakPtr>(weak_ptr),
305 std::forward<RunArgs>(args)...);
306 }
307};
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900308
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900309// Invoker<>
310//
311// See description at the top of the file.
tzikfa6c9852016-06-28 21:22:21 +0900312template <typename StorageType, typename UnboundRunType>
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900313struct Invoker;
314
tzikfa6c9852016-06-28 21:22:21 +0900315template <typename StorageType, typename R, typename... UnboundArgs>
316struct Invoker<StorageType, R(UnboundArgs...)> {
tzik0d4bab22016-03-09 14:46:05 +0900317 static R Run(BindStateBase* base, UnboundArgs&&... unbound_args) {
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900318 // Local references to make debugger stepping easier. If in a debugger,
319 // you really want to warp ahead and step through the
320 // InvokeHelper<>::MakeItSo() call below.
tzikfa6c9852016-06-28 21:22:21 +0900321 const StorageType* storage = static_cast<StorageType*>(base);
322 static constexpr size_t num_bound_args =
323 std::tuple_size<decltype(storage->bound_args_)>::value;
tzik9f27e1f2016-07-01 14:54:12 +0900324 return RunImpl(storage->functor_,
tzikfa6c9852016-06-28 21:22:21 +0900325 storage->bound_args_,
326 MakeIndexSequence<num_bound_args>(),
327 std::forward<UnboundArgs>(unbound_args)...);
328 }
329
tzik9f27e1f2016-07-01 14:54:12 +0900330 private:
331 template <typename Functor, typename BoundArgsTuple, size_t... indices>
332 static inline R RunImpl(Functor&& functor,
tzikfa6c9852016-06-28 21:22:21 +0900333 BoundArgsTuple&& bound,
334 IndexSequence<indices...>,
335 UnboundArgs&&... unbound_args) {
336 static constexpr bool is_method =
tzik9f27e1f2016-07-01 14:54:12 +0900337 FunctorTraits<typename std::decay<Functor>::type>::is_method;
tzikfa6c9852016-06-28 21:22:21 +0900338
339 using DecayedArgsTuple = typename std::decay<BoundArgsTuple>::type;
340 static constexpr bool is_weak_call =
341 IsWeakMethod<is_method,
342 typename std::tuple_element<
343 indices,
344 DecayedArgsTuple>::type...>::value;
345
tzike1ad6f62016-06-01 17:22:51 +0900346 return InvokeHelper<is_weak_call, R>::MakeItSo(
tzik9f27e1f2016-07-01 14:54:12 +0900347 std::forward<Functor>(functor),
348 Unwrap(base::get<indices>(std::forward<BoundArgsTuple>(bound)))...,
tzik0d4bab22016-03-09 14:46:05 +0900349 std::forward<UnboundArgs>(unbound_args)...);
ajwong@chromium.org6f015bd2011-11-29 07:13:54 +0900350 }
351};
352
tzikfa6c9852016-06-28 21:22:21 +0900353// Used to implement MakeUnboundRunType.
354template <typename Functor, typename... BoundArgs>
355struct MakeUnboundRunTypeImpl {
tzik9f27e1f2016-07-01 14:54:12 +0900356 using RunType =
357 typename FunctorTraits<typename std::decay<Functor>::type>::RunType;
tzikfa6c9852016-06-28 21:22:21 +0900358 using ReturnType = ExtractReturnType<RunType>;
359 using Args = ExtractArgs<RunType>;
360 using UnboundArgs = DropTypeListItem<sizeof...(BoundArgs), Args>;
361 using Type = MakeFunctionType<ReturnType, UnboundArgs>;
362};
tzik31d3fae2016-07-08 18:42:38 +0900363template <typename Functor>
364typename std::enable_if<FunctorTraits<Functor>::is_nullable, bool>::type
365IsNull(const Functor& functor) {
366 return !functor;
367}
368
369template <typename Functor>
370typename std::enable_if<!FunctorTraits<Functor>::is_nullable, bool>::type
371IsNull(const Functor&) {
372 return false;
373}
tzikfa6c9852016-06-28 21:22:21 +0900374
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900375// BindState<>
376//
tzik9f27e1f2016-07-01 14:54:12 +0900377// This stores all the state passed into Bind().
378template <typename Functor, typename... BoundArgs>
379struct BindState final : BindStateBase {
tzikb4ec92d2016-07-08 23:14:01 +0900380 template <typename ForwardFunctor, typename... ForwardBoundArgs>
381 explicit BindState(ForwardFunctor&& functor, ForwardBoundArgs&&... bound_args)
tapted9cef4212015-05-14 17:03:32 +0900382 : BindStateBase(&Destroy),
tzikb4ec92d2016-07-08 23:14:01 +0900383 functor_(std::forward<ForwardFunctor>(functor)),
tzik9f27e1f2016-07-01 14:54:12 +0900384 bound_args_(std::forward<ForwardBoundArgs>(bound_args)...) {
tzik31d3fae2016-07-08 18:42:38 +0900385 DCHECK(!IsNull(functor_));
tzik9f27e1f2016-07-01 14:54:12 +0900386 }
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +0900387
tzik9f27e1f2016-07-01 14:54:12 +0900388 Functor functor_;
389 std::tuple<BoundArgs...> bound_args_;
dmichael2f7bc202014-12-19 07:30:11 +0900390
391 private:
tapted9cef4212015-05-14 17:03:32 +0900392 ~BindState() {}
393
394 static void Destroy(BindStateBase* self) {
395 delete static_cast<BindState*>(self);
396 }
ajwong@chromium.org6f015bd2011-11-29 07:13:54 +0900397};
398
tzik9f27e1f2016-07-01 14:54:12 +0900399// Used to implement MakeBindStateType.
400template <bool is_method, typename Functor, typename... BoundArgs>
401struct MakeBindStateTypeImpl;
402
403template <typename Functor, typename... BoundArgs>
404struct MakeBindStateTypeImpl<false, Functor, BoundArgs...> {
405 static_assert(!HasRefCountedTypeAsRawPtr<BoundArgs...>::value,
406 "A parameter is a refcounted type and needs scoped_refptr.");
407 using Type = BindState<typename std::decay<Functor>::type,
408 typename std::decay<BoundArgs>::type...>;
409};
410
411template <typename Functor>
412struct MakeBindStateTypeImpl<true, Functor> {
413 using Type = BindState<typename std::decay<Functor>::type>;
414};
415
416template <typename Functor, typename Receiver, typename... BoundArgs>
417struct MakeBindStateTypeImpl<true, Functor, Receiver, BoundArgs...> {
418 static_assert(
419 !std::is_array<typename std::remove_reference<Receiver>::type>::value,
420 "First bound argument to a method cannot be an array.");
421 static_assert(!HasRefCountedTypeAsRawPtr<BoundArgs...>::value,
422 "A parameter is a refcounted type and needs scoped_refptr.");
423
424 private:
425 using DecayedReceiver = typename std::decay<Receiver>::type;
426
427 public:
428 using Type = BindState<
429 typename std::decay<Functor>::type,
430 typename std::conditional<
431 std::is_pointer<DecayedReceiver>::value,
432 scoped_refptr<typename std::remove_pointer<DecayedReceiver>::type>,
433 DecayedReceiver>::type,
434 typename std::decay<BoundArgs>::type...>;
435};
436
437template <typename Functor, typename... BoundArgs>
438using MakeBindStateType = typename MakeBindStateTypeImpl<
439 FunctorTraits<typename std::decay<Functor>::type>::is_method,
440 Functor,
441 BoundArgs...>::Type;
442
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900443} // namespace internal
tzikfa6c9852016-06-28 21:22:21 +0900444
445// Returns a RunType of bound functor.
446// E.g. MakeUnboundRunType<R(A, B, C), A, B> is evaluated to R(C).
447template <typename Functor, typename... BoundArgs>
448using MakeUnboundRunType =
449 typename internal::MakeUnboundRunTypeImpl<Functor, BoundArgs...>::Type;
450
ajwong@chromium.orge2cca632011-02-15 10:27:38 +0900451} // namespace base
452
453#endif // BASE_BIND_INTERNAL_H_