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 <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <type_traits> | 10 #include <type_traits> |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 // BindsArrayToFirstArg selects true_type when |is_method| is true and the first | 98 // BindsArrayToFirstArg selects true_type when |is_method| is true and the first |
99 // item of |Args| is an array type. | 99 // item of |Args| is an array type. |
100 // Implementation note: This non-specialized case handles !is_method case and | 100 // Implementation note: This non-specialized case handles !is_method case and |
101 // zero-arity case only. Other cases should be handled by the specialization | 101 // zero-arity case only. Other cases should be handled by the specialization |
102 // below. | 102 // below. |
103 template <bool is_method, typename... Args> | 103 template <bool is_method, typename... Args> |
104 struct BindsArrayToFirstArg : false_type {}; | 104 struct BindsArrayToFirstArg : false_type {}; |
105 | 105 |
106 template <typename T, typename... Args> | 106 template <typename T, typename... Args> |
107 struct BindsArrayToFirstArg<true, T, Args...> : is_array<T> {}; | 107 struct BindsArrayToFirstArg<true, T, Args...> |
| 108 : is_array<typename std::remove_reference<T>::type> {}; |
108 | 109 |
109 // HasRefCountedParamAsRawPtr is the same to HasRefCountedTypeAsRawPtr except | 110 // HasRefCountedParamAsRawPtr is the same to HasRefCountedTypeAsRawPtr except |
110 // when |is_method| is true HasRefCountedParamAsRawPtr skips the first argument. | 111 // when |is_method| is true HasRefCountedParamAsRawPtr skips the first argument. |
111 // Implementation note: This non-specialized case handles !is_method case and | 112 // Implementation note: This non-specialized case handles !is_method case and |
112 // zero-arity case only. Other cases should be handled by the specialization | 113 // zero-arity case only. Other cases should be handled by the specialization |
113 // below. | 114 // below. |
114 template <bool is_method, typename... Args> | 115 template <bool is_method, typename... Args> |
115 struct HasRefCountedParamAsRawPtr : HasRefCountedTypeAsRawPtr<Args...> {}; | 116 struct HasRefCountedParamAsRawPtr : HasRefCountedTypeAsRawPtr<Args...> {}; |
116 | 117 |
117 template <typename T, typename... Args> | 118 template <typename T, typename... Args> |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 using InvokeHelperType = | 395 using InvokeHelperType = |
395 InvokeHelper<IsWeakCall::value, R, Runnable, InvokeHelperArgs>; | 396 InvokeHelper<IsWeakCall::value, R, Runnable, InvokeHelperArgs>; |
396 | 397 |
397 using UnboundArgs = DropTypeListItem<sizeof...(BoundArgs), TypeList<Args...>>; | 398 using UnboundArgs = DropTypeListItem<sizeof...(BoundArgs), TypeList<Args...>>; |
398 | 399 |
399 public: | 400 public: |
400 using InvokerType = Invoker<BoundIndices, StorageType, Unwrappers, | 401 using InvokerType = Invoker<BoundIndices, StorageType, Unwrappers, |
401 InvokeHelperType, UnboundForwardRunType>; | 402 InvokeHelperType, UnboundForwardRunType>; |
402 using UnboundRunType = MakeFunctionType<R, UnboundArgs>; | 403 using UnboundRunType = MakeFunctionType<R, UnboundArgs>; |
403 | 404 |
404 BindState(const Runnable& runnable, const BoundArgs&... bound_args) | 405 template <typename... ForwardArgs> |
| 406 BindState(const Runnable& runnable, ForwardArgs&&... bound_args) |
405 : BindStateBase(&Destroy), | 407 : BindStateBase(&Destroy), |
406 runnable_(runnable), | 408 runnable_(runnable), |
407 ref_(bound_args...), | 409 ref_(bound_args...), |
408 bound_args_(bound_args...) {} | 410 bound_args_(std::forward<ForwardArgs>(bound_args)...) {} |
409 | 411 |
410 RunnableType runnable_; | 412 RunnableType runnable_; |
411 MaybeScopedRefPtr<HasIsMethodTag<Runnable>::value, BoundArgs...> ref_; | 413 MaybeScopedRefPtr<HasIsMethodTag<Runnable>::value, BoundArgs...> ref_; |
412 Tuple<BoundArgs...> bound_args_; | 414 Tuple<BoundArgs...> bound_args_; |
413 | 415 |
414 private: | 416 private: |
415 ~BindState() {} | 417 ~BindState() {} |
416 | 418 |
417 static void Destroy(BindStateBase* self) { | 419 static void Destroy(BindStateBase* self) { |
418 delete static_cast<BindState*>(self); | 420 delete static_cast<BindState*>(self); |
419 } | 421 } |
420 }; | 422 }; |
421 | 423 |
422 } // namespace internal | 424 } // namespace internal |
423 } // namespace base | 425 } // namespace base |
424 | 426 |
425 #endif // BASE_BIND_INTERNAL_H_ | 427 #endif // BASE_BIND_INTERNAL_H_ |
OLD | NEW |