| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This file contains utility functions and classes that help the | 5 // This file contains utility functions and classes that help the |
| 6 // implementation, and management of the Callback objects. | 6 // implementation, and management of the Callback objects. |
| 7 | 7 |
| 8 #ifndef BASE_CALLBACK_INTERNAL_H_ | 8 #ifndef BASE_CALLBACK_INTERNAL_H_ |
| 9 #define BASE_CALLBACK_INTERNAL_H_ | 9 #define BASE_CALLBACK_INTERNAL_H_ |
| 10 | 10 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // A helper template to determine if given type is non-const move-only-type, | 70 // A helper template to determine if given type is non-const move-only-type, |
| 71 // i.e. if a value of the given type should be passed via .Pass() in a | 71 // i.e. if a value of the given type should be passed via .Pass() in a |
| 72 // destructive way. | 72 // destructive way. |
| 73 template <typename T> struct IsMoveOnlyType { | 73 template <typename T> struct IsMoveOnlyType { |
| 74 template <typename U> | 74 template <typename U> |
| 75 static YesType Test(const typename U::MoveOnlyTypeForCPP03*); | 75 static YesType Test(const typename U::MoveOnlyTypeForCPP03*); |
| 76 | 76 |
| 77 template <typename U> | 77 template <typename U> |
| 78 static NoType Test(...); | 78 static NoType Test(...); |
| 79 | 79 |
| 80 static const bool value = sizeof(Test<T>(0)) == sizeof(YesType) && | 80 static const bool value = sizeof((Test<T>(0))) == sizeof(YesType) && |
| 81 !is_const<T>::value; | 81 !is_const<T>::value; |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 // This is a typetraits object that's used to take an argument type, and | 84 // This is a typetraits object that's used to take an argument type, and |
| 85 // extract a suitable type for storing and forwarding arguments. | 85 // extract a suitable type for storing and forwarding arguments. |
| 86 // | 86 // |
| 87 // In particular, it strips off references, and converts arrays to | 87 // In particular, it strips off references, and converts arrays to |
| 88 // pointers for storage; and it avoids accidentally trying to create a | 88 // pointers for storage; and it avoids accidentally trying to create a |
| 89 // "reference of a reference" if the argument is a reference type. | 89 // "reference of a reference" if the argument is a reference type. |
| 90 // | 90 // |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 169 |
| 170 template <typename T> | 170 template <typename T> |
| 171 typename enable_if<IsMoveOnlyType<T>::value, T>::type CallbackForward(T& t) { | 171 typename enable_if<IsMoveOnlyType<T>::value, T>::type CallbackForward(T& t) { |
| 172 return t.Pass(); | 172 return t.Pass(); |
| 173 } | 173 } |
| 174 | 174 |
| 175 } // namespace internal | 175 } // namespace internal |
| 176 } // namespace base | 176 } // namespace base |
| 177 | 177 |
| 178 #endif // BASE_CALLBACK_INTERNAL_H_ | 178 #endif // BASE_CALLBACK_INTERNAL_H_ |
| OLD | NEW |