| 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 <tuple> | 10 #include <tuple> |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 template <typename ReturnType> | 288 template <typename ReturnType> |
| 289 struct InvokeHelper<true, ReturnType> { | 289 struct InvokeHelper<true, ReturnType> { |
| 290 // WeakCalls are only supported for functions with a void return type. | 290 // WeakCalls are only supported for functions with a void return type. |
| 291 // Otherwise, the function result would be undefined if the the WeakPtr<> | 291 // Otherwise, the function result would be undefined if the the WeakPtr<> |
| 292 // is invalidated. | 292 // is invalidated. |
| 293 static_assert(std::is_void<ReturnType>::value, | 293 static_assert(std::is_void<ReturnType>::value, |
| 294 "weak_ptrs can only bind to methods without return values"); | 294 "weak_ptrs can only bind to methods without return values"); |
| 295 | 295 |
| 296 template <typename Functor, typename BoundWeakPtr, typename... RunArgs> | 296 template <typename Functor, typename BoundWeakPtr, typename... RunArgs> |
| 297 static inline void MakeItSo(Functor&& functor, | 297 static inline void MakeItSo(Functor&& functor, |
| 298 BoundWeakPtr weak_ptr, | 298 BoundWeakPtr&& weak_ptr, |
| 299 RunArgs&&... args) { | 299 RunArgs&&... args) { |
| 300 if (!weak_ptr) | 300 if (!weak_ptr) |
| 301 return; | 301 return; |
| 302 using Traits = FunctorTraits<typename std::decay<Functor>::type>; | 302 using Traits = FunctorTraits<typename std::decay<Functor>::type>; |
| 303 Traits::Invoke(std::forward<Functor>(functor), | 303 Traits::Invoke(std::forward<Functor>(functor), |
| 304 std::forward<BoundWeakPtr>(weak_ptr), | 304 std::forward<BoundWeakPtr>(weak_ptr), |
| 305 std::forward<RunArgs>(args)...); | 305 std::forward<RunArgs>(args)...); |
| 306 } | 306 } |
| 307 }; | 307 }; |
| 308 | 308 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 | 444 |
| 445 // Returns a RunType of bound functor. | 445 // Returns a RunType of bound functor. |
| 446 // E.g. MakeUnboundRunType<R(A, B, C), A, B> is evaluated to R(C). | 446 // E.g. MakeUnboundRunType<R(A, B, C), A, B> is evaluated to R(C). |
| 447 template <typename Functor, typename... BoundArgs> | 447 template <typename Functor, typename... BoundArgs> |
| 448 using MakeUnboundRunType = | 448 using MakeUnboundRunType = |
| 449 typename internal::MakeUnboundRunTypeImpl<Functor, BoundArgs...>::Type; | 449 typename internal::MakeUnboundRunTypeImpl<Functor, BoundArgs...>::Type; |
| 450 | 450 |
| 451 } // namespace base | 451 } // namespace base |
| 452 | 452 |
| 453 #endif // BASE_BIND_INTERNAL_H_ | 453 #endif // BASE_BIND_INTERNAL_H_ |
| OLD | NEW |