1 // 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_H_
6 #define BASE_BIND_H_
7 
8 #include "base/bind_internal.h"
9 
10 // -----------------------------------------------------------------------------
11 // Usage documentation
12 // -----------------------------------------------------------------------------
13 //
14 // See base/callback.h for documentation.
15 //
16 //
17 // -----------------------------------------------------------------------------
18 // Implementation notes
19 // -----------------------------------------------------------------------------
20 //
21 // If you're reading the implementation, before proceeding further, you should
22 // read the top comment of base/bind_internal.h for a definition of common
23 // terms and concepts.
24 
25 namespace base {
26 
27 template <typename Functor, typename... Args>
Bind(Functor && functor,Args &&...args)28 inline base::Callback<MakeUnboundRunType<Functor, Args...>> Bind(
29     Functor&& functor,
30     Args&&... args) {
31   using BindState = internal::MakeBindStateType<Functor, Args...>;
32   using UnboundRunType = MakeUnboundRunType<Functor, Args...>;
33   using Invoker = internal::Invoker<BindState, UnboundRunType>;
34 
35   using CallbackType = Callback<UnboundRunType>;
36   return CallbackType(new BindState(std::forward<Functor>(functor),
37                                     std::forward<Args>(args)...),
38                       &Invoker::Run);
39 }
40 
41 }  // namespace base
42 
43 #endif  // BASE_BIND_H_
44