| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_UTIL_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_UTIL_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_UTIL_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_UTIL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 } | 206 } |
| 207 | 207 |
| 208 static void* GetNext(SerializationContext* context) { return nullptr; } | 208 static void* GetNext(SerializationContext* context) { return nullptr; } |
| 209 | 209 |
| 210 template <typename MaybeConstUserType> | 210 template <typename MaybeConstUserType> |
| 211 static void TearDown(MaybeConstUserType& input, void* custom_context) { | 211 static void TearDown(MaybeConstUserType& input, void* custom_context) { |
| 212 DCHECK(!custom_context); | 212 DCHECK(!custom_context); |
| 213 } | 213 } |
| 214 }; | 214 }; |
| 215 | 215 |
| 216 template <typename ReturnType, typename ParamType, typename MaybeConstUserType> | 216 template <typename ReturnType, typename ParamType, typename InputUserType> |
| 217 ReturnType CallWithContext(ReturnType (*f)(ParamType, void*), | 217 ReturnType CallWithContext(ReturnType (*f)(ParamType, void*), |
| 218 MaybeConstUserType& input, | 218 InputUserType&& input, |
| 219 void* context) { | 219 void* context) { |
| 220 return f(input, context); | 220 return f(std::forward<InputUserType>(input), context); |
| 221 } | 221 } |
| 222 | 222 |
| 223 template <typename ReturnType, typename ParamType, typename MaybeConstUserType> | 223 template <typename ReturnType, typename ParamType, typename InputUserType> |
| 224 ReturnType CallWithContext(ReturnType (*f)(ParamType), | 224 ReturnType CallWithContext(ReturnType (*f)(ParamType), |
| 225 MaybeConstUserType& input, | 225 InputUserType&& input, |
| 226 void* context) { | 226 void* context) { |
| 227 return f(input); | 227 return f(std::forward<InputUserType>(input)); |
| 228 } | 228 } |
| 229 | 229 |
| 230 } // namespace internal | 230 } // namespace internal |
| 231 } // namespace mojo | 231 } // namespace mojo |
| 232 | 232 |
| 233 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_UTIL_H_ | 233 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_UTIL_H_ |
| OLD | NEW |