blob: 50b941e45992b145dde1b45e9718c47b3d9956f4 [file] [log] [blame]
[email protected]b38d3572011-02-15 01:27:381// 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_
[email protected]b38d3572011-02-15 01:27:387
8#include "base/bind_internal.h"
[email protected]b38d3572011-02-15 01:27:389
[email protected]24292642012-07-12 20:06:4010// -----------------------------------------------------------------------------
11// Usage documentation
12// -----------------------------------------------------------------------------
[email protected]b38d3572011-02-15 01:27:3813//
tzik703f1562016-09-02 07:36:5514// See //docs/callback.md for documentation.
[email protected]24292642012-07-12 20:06:4015//
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.
[email protected]b38d3572011-02-15 01:27:3824
25namespace base {
26
tzik401dd3672014-11-26 07:54:5827template <typename Functor, typename... Args>
tzik99de02b2016-07-01 05:54:1228inline base::Callback<MakeUnboundRunType<Functor, Args...>> Bind(
29 Functor&& functor,
30 Args&&... args) {
31 using BindState = internal::MakeBindStateType<Functor, Args...>;
tzikcaf1d84b2016-06-28 12:22:2132 using UnboundRunType = MakeUnboundRunType<Functor, Args...>;
tzikcaf1d84b2016-06-28 12:22:2133 using Invoker = internal::Invoker<BindState, UnboundRunType>;
[email protected]e24f8762011-12-20 00:10:0434
tzik99de02b2016-07-01 05:54:1235 using CallbackType = Callback<UnboundRunType>;
36 return CallbackType(new BindState(std::forward<Functor>(functor),
tzikcaf1d84b2016-06-28 12:22:2137 std::forward<Args>(args)...),
38 &Invoker::Run);
[email protected]fccef1552011-11-28 22:13:5439}
40
[email protected]b38d3572011-02-15 01:27:3841} // namespace base
42
43#endif // BASE_BIND_H_