OLD | NEW |
(Empty) | |
| 1 // This file was GENERATED by command: |
| 2 // pump.py bind.h.pump |
| 3 // DO NOT EDIT BY HAND!!! |
| 4 |
| 5 |
| 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. |
| 9 |
| 10 #ifndef BASE_BIND_H_ |
| 11 #define BASE_BIND_H_ |
| 12 #pragma once |
| 13 |
| 14 #include "base/bind_internal.h" |
| 15 #include "base/callback_helpers.h" |
| 16 |
| 17 // See base/callback.h for how to use these functions. |
| 18 // |
| 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. |
| 26 // |
| 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. |
| 33 |
| 34 namespace base { |
| 35 |
| 36 template <typename Sig> |
| 37 internal::InvokerStorageHolder<internal::InvokerStorage0<Sig> > |
| 38 Bind(Sig f) { |
| 39 return internal::MakeInvokerStorageHolder( |
| 40 new internal::InvokerStorage0<Sig>(f)); |
| 41 } |
| 42 |
| 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)); |
| 49 } |
| 50 |
| 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)); |
| 57 } |
| 58 |
| 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)); |
| 65 } |
| 66 |
| 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)); |
| 73 } |
| 74 |
| 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)); |
| 84 } |
| 85 |
| 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)); |
| 95 } |
| 96 |
| 97 } // namespace base |
| 98 |
| 99 #endif // BASE_BIND_H_ |
OLD | NEW |