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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 // | 198 // |
199 // In C++11, std::forward would replace all uses of this function. However, it | 199 // In C++11, std::forward would replace all uses of this function. However, it |
200 // is impossible to implement a general std::forward with C++11 due to a lack | 200 // is impossible to implement a general std::forward with C++11 due to a lack |
201 // of rvalue references. | 201 // of rvalue references. |
202 // | 202 // |
203 // In addition to Callback/Bind, this is used by PostTaskAndReplyWithResult to | 203 // In addition to Callback/Bind, this is used by PostTaskAndReplyWithResult to |
204 // simulate std::forward() and forward the result of one Callback as a | 204 // simulate std::forward() and forward the result of one Callback as a |
205 // parameter to another callback. This is to support Callbacks that return | 205 // parameter to another callback. This is to support Callbacks that return |
206 // the movable-but-not-copyable types whitelisted above. | 206 // the movable-but-not-copyable types whitelisted above. |
207 template <typename T> | 207 template <typename T> |
208 typename enable_if<!IsMoveOnlyType<T>::value, T>::type& CallbackForward(T& t) { | 208 typename std::enable_if<!IsMoveOnlyType<T>::value, T>::type& CallbackForward( |
| 209 T& t) { |
209 return t; | 210 return t; |
210 } | 211 } |
211 | 212 |
212 template <typename T> | 213 template <typename T> |
213 typename enable_if<IsMoveOnlyType<T>::value, T>::type CallbackForward(T& t) { | 214 typename std::enable_if<IsMoveOnlyType<T>::value, T>::type CallbackForward( |
| 215 T& t) { |
214 return t.Pass(); | 216 return t.Pass(); |
215 } | 217 } |
216 | 218 |
217 } // namespace internal | 219 } // namespace internal |
218 } // namespace base | 220 } // namespace base |
219 | 221 |
220 #endif // BASE_CALLBACK_INTERNAL_H_ | 222 #endif // BASE_CALLBACK_INTERNAL_H_ |
OLD | NEW |