| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 // std::unique_ptr. | 104 // std::unique_ptr. |
| 105 // TODO(dcheng): Revisit this when Windows switches to VS2015 by default. | 105 // TODO(dcheng): Revisit this when Windows switches to VS2015 by default. |
| 106 template <typename T> struct IsMoveOnlyType { | 106 template <typename T> struct IsMoveOnlyType { |
| 107 template <typename U> | 107 template <typename U> |
| 108 static YesType Test(const typename U::MoveOnlyTypeForCPP03*); | 108 static YesType Test(const typename U::MoveOnlyTypeForCPP03*); |
| 109 | 109 |
| 110 template <typename U> | 110 template <typename U> |
| 111 static NoType Test(...); | 111 static NoType Test(...); |
| 112 | 112 |
| 113 static const bool value = sizeof((Test<T>(0))) == sizeof(YesType) && | 113 static const bool value = sizeof((Test<T>(0))) == sizeof(YesType) && |
| 114 !is_const<T>::value; | 114 !std::is_const<T>::value; |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 // Specialization of IsMoveOnlyType so that std::unique_ptr is still considered | 117 // Specialization of IsMoveOnlyType so that std::unique_ptr is still considered |
| 118 // move-only, even without the sentinel member. | 118 // move-only, even without the sentinel member. |
| 119 template <typename T, typename D> | 119 template <typename T, typename D> |
| 120 struct IsMoveOnlyType<std::unique_ptr<T, D>> : std::true_type {}; | 120 struct IsMoveOnlyType<std::unique_ptr<T, D>> : std::true_type {}; |
| 121 | 121 |
| 122 // Specialization of std::vector, so that it's considered move-only if the | 122 // Specialization of std::vector, so that it's considered move-only if the |
| 123 // element type is move-only. Allocator is explicitly ignored when determining | 123 // element type is move-only. Allocator is explicitly ignored when determining |
| 124 // move-only status of the std::vector. | 124 // move-only status of the std::vector. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 template <typename T> | 208 template <typename T> |
| 209 typename std::enable_if<IsMoveOnlyType<T>::value, T>::type CallbackForward( | 209 typename std::enable_if<IsMoveOnlyType<T>::value, T>::type CallbackForward( |
| 210 T& t) { | 210 T& t) { |
| 211 return std::move(t); | 211 return std::move(t); |
| 212 } | 212 } |
| 213 | 213 |
| 214 } // namespace internal | 214 } // namespace internal |
| 215 } // namespace base | 215 } // namespace base |
| 216 | 216 |
| 217 #endif // BASE_CALLBACK_INTERNAL_H_ | 217 #endif // BASE_CALLBACK_INTERNAL_H_ |
| OLD | NEW |