aboutsummaryrefslogtreecommitdiff
path: root/third_party/chromium/base/bind.h
blob: 9cf65b67764b0cbcb393cd392f6fdb480d57496b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef BASE_BIND_H_
#define BASE_BIND_H_

#include "base/bind_internal.h"

// -----------------------------------------------------------------------------
// Usage documentation
// -----------------------------------------------------------------------------
//
// See base/callback.h for documentation.
//
//
// -----------------------------------------------------------------------------
// Implementation notes
// -----------------------------------------------------------------------------
//
// If you're reading the implementation, before proceeding further, you should
// read the top comment of base/bind_internal.h for a definition of common
// terms and concepts.

namespace base {

template <typename Functor, typename... Args>
inline base::Callback<MakeUnboundRunType<Functor, Args...>> Bind(
    Functor&& functor,
    Args&&... args) {
  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);
}

}  // namespace base

#endif  // BASE_BIND_H_