OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_BIND_INTERNAL_H_ | 5 #ifndef BASE_BIND_INTERNAL_H_ |
6 #define BASE_BIND_INTERNAL_H_ | 6 #define BASE_BIND_INTERNAL_H_ |
7 | 7 |
8 #include <type_traits> | 8 #include <type_traits> |
9 | 9 |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // Invoker<>. | 58 // Invoker<>. |
59 // Invoker<> -- Unwraps the curried parameters and executes the Runnable. | 59 // Invoker<> -- Unwraps the curried parameters and executes the Runnable. |
60 // BindState<> -- Stores the curried parameters, and is the main entry point | 60 // BindState<> -- Stores the curried parameters, and is the main entry point |
61 // into the Bind() system, doing most of the type resolution. | 61 // into the Bind() system, doing most of the type resolution. |
62 // There are ARITY BindState types. | 62 // There are ARITY BindState types. |
63 | 63 |
64 // HasNonConstReferenceParam selects true_type when any of the parameters in | 64 // HasNonConstReferenceParam selects true_type when any of the parameters in |
65 // |Sig| is a non-const reference. | 65 // |Sig| is a non-const reference. |
66 // Implementation note: This non-specialized case handles zero-arity case only. | 66 // Implementation note: This non-specialized case handles zero-arity case only. |
67 // Non-zero-arity cases should be handled by the specialization below. | 67 // Non-zero-arity cases should be handled by the specialization below. |
68 template <typename Sig> | 68 template <typename List> |
69 struct HasNonConstReferenceParam : false_type {}; | 69 struct HasNonConstReferenceItem : false_type {}; |
70 | 70 |
71 // Implementation note: Select true_type if the first parameter is a non-const | 71 // Implementation note: Select true_type if the first parameter is a non-const |
72 // reference. Otherwise, skip the first parameter and check rest of parameters | 72 // reference. Otherwise, skip the first parameter and check rest of parameters |
73 // recursively. | 73 // recursively. |
74 template <typename R, typename T, typename... Args> | 74 template <typename T, typename... Args> |
75 struct HasNonConstReferenceParam<R(T, Args...)> | 75 struct HasNonConstReferenceItem<TypeList<T, Args...>> |
76 : std::conditional<is_non_const_reference<T>::value, | 76 : std::conditional<is_non_const_reference<T>::value, |
77 true_type, | 77 true_type, |
78 HasNonConstReferenceParam<R(Args...)>>::type {}; | 78 HasNonConstReferenceItem<TypeList<Args...>>>::type {}; |
79 | 79 |
80 // HasRefCountedTypeAsRawPtr selects true_type when any of the |Args| is a raw | 80 // HasRefCountedTypeAsRawPtr selects true_type when any of the |Args| is a raw |
81 // pointer to a RefCounted type. | 81 // pointer to a RefCounted type. |
82 // Implementation note: This non-specialized case handles zero-arity case only. | 82 // Implementation note: This non-specialized case handles zero-arity case only. |
83 // Non-zero-arity cases should be handled by the specialization below. | 83 // Non-zero-arity cases should be handled by the specialization below. |
84 template <typename... Args> | 84 template <typename... Args> |
85 struct HasRefCountedTypeAsRawPtr : false_type {}; | 85 struct HasRefCountedTypeAsRawPtr : false_type {}; |
86 | 86 |
87 // Implementation note: Select true_type if the first parameter is a raw pointer | 87 // Implementation note: Select true_type if the first parameter is a raw pointer |
88 // to a RefCounted type. Otherwise, skip the first parameter and check rest of | 88 // to a RefCounted type. Otherwise, skip the first parameter and check rest of |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 | 408 |
409 static void Destroy(BindStateBase* self) { | 409 static void Destroy(BindStateBase* self) { |
410 delete static_cast<BindState*>(self); | 410 delete static_cast<BindState*>(self); |
411 } | 411 } |
412 }; | 412 }; |
413 | 413 |
414 } // namespace internal | 414 } // namespace internal |
415 } // namespace base | 415 } // namespace base |
416 | 416 |
417 #endif // BASE_BIND_INTERNAL_H_ | 417 #endif // BASE_BIND_INTERNAL_H_ |
OLD | NEW |