Dispose of NPOject in npobject_identity_test.cc
[chromium-blink-merge.git] / base / bind.h
blobcd9eb193279f77f02140568e3a26dbdc1c90889d
1 // This file was GENERATED by command:
2 // pump.py bind.h.pump
3 // DO NOT EDIT BY HAND!!!
6 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
7 // Use of this source code is governed by a BSD-style license that can be
8 // found in the LICENSE file.
10 #ifndef BASE_BIND_H_
11 #define BASE_BIND_H_
12 #pragma once
14 #include "base/bind_internal.h"
15 #include "base/callback_internal.h"
17 // See base/callback.h for how to use these functions.
19 // IMPLEMENTATION NOTE
20 // Though Bind()'s result is meant to be stored in a Callback<> type, it
21 // cannot actually return the exact type without requiring a large amount
22 // of extra template specializations. The problem is that in order to
23 // discern the correct specialization of Callback<>, Bind would need to
24 // unwrap the function signature to determine the signature's arity, and
25 // whether or not it is a method.
27 // Each unique combination of (arity, function_type, num_prebound) where
28 // function_type is one of {function, method, const_method} would require
29 // one specialization. We eventually have to do a similar number of
30 // specializations anyways in the implementation (see the FunctionTraitsN,
31 // classes). However, it is avoidable in Bind if we return the result
32 // via an indirection like we do below.
34 namespace base {
36 template <typename Sig>
37 internal::InvokerStorageHolder<internal::InvokerStorage0<Sig> >
38 Bind(Sig f) {
39 return internal::MakeInvokerStorageHolder(
40 new internal::InvokerStorage0<Sig>(f));
43 template <typename Sig, typename P1>
44 internal::InvokerStorageHolder<internal::InvokerStorage1<Sig,P1> >
45 Bind(Sig f, const P1& p1) {
46 return internal::MakeInvokerStorageHolder(
47 new internal::InvokerStorage1<Sig, P1>(
48 f, p1));
51 template <typename Sig, typename P1, typename P2>
52 internal::InvokerStorageHolder<internal::InvokerStorage2<Sig,P1, P2> >
53 Bind(Sig f, const P1& p1, const P2& p2) {
54 return internal::MakeInvokerStorageHolder(
55 new internal::InvokerStorage2<Sig, P1, P2>(
56 f, p1, p2));
59 template <typename Sig, typename P1, typename P2, typename P3>
60 internal::InvokerStorageHolder<internal::InvokerStorage3<Sig,P1, P2, P3> >
61 Bind(Sig f, const P1& p1, const P2& p2, const P3& p3) {
62 return internal::MakeInvokerStorageHolder(
63 new internal::InvokerStorage3<Sig, P1, P2, P3>(
64 f, p1, p2, p3));
67 template <typename Sig, typename P1, typename P2, typename P3, typename P4>
68 internal::InvokerStorageHolder<internal::InvokerStorage4<Sig,P1, P2, P3, P4> >
69 Bind(Sig f, const P1& p1, const P2& p2, const P3& p3, const P4& p4) {
70 return internal::MakeInvokerStorageHolder(
71 new internal::InvokerStorage4<Sig, P1, P2, P3, P4>(
72 f, p1, p2, p3, p4));
75 template <typename Sig, typename P1, typename P2, typename P3, typename P4,
76 typename P5>
77 internal::InvokerStorageHolder<internal::InvokerStorage5<Sig,P1, P2, P3, P4,
78 P5> >
79 Bind(Sig f, const P1& p1, const P2& p2, const P3& p3, const P4& p4,
80 const P5& p5) {
81 return internal::MakeInvokerStorageHolder(
82 new internal::InvokerStorage5<Sig, P1, P2, P3, P4, P5>(
83 f, p1, p2, p3, p4, p5));
86 template <typename Sig, typename P1, typename P2, typename P3, typename P4,
87 typename P5, typename P6>
88 internal::InvokerStorageHolder<internal::InvokerStorage6<Sig,P1, P2, P3, P4,
89 P5, P6> >
90 Bind(Sig f, const P1& p1, const P2& p2, const P3& p3, const P4& p4,
91 const P5& p5, const P6& p6) {
92 return internal::MakeInvokerStorageHolder(
93 new internal::InvokerStorage6<Sig, P1, P2, P3, P4, P5, P6>(
94 f, p1, p2, p3, p4, p5, p6));
97 } // namespace base
99 #endif // BASE_BIND_H_