| 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 #ifndef COMPONENTS_SYNC_BASE_IMMUTABLE_H_ | 5 #ifndef COMPONENTS_SYNC_BASE_IMMUTABLE_H_ |
| 6 #define COMPONENTS_SYNC_BASE_IMMUTABLE_H_ | 6 #define COMPONENTS_SYNC_BASE_IMMUTABLE_H_ |
| 7 | 7 |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 // delete *wrapper; | 180 // delete *wrapper; |
| 181 // } | 181 // } |
| 182 // | 182 // |
| 183 // ... | 183 // ... |
| 184 // | 184 // |
| 185 // Also note that this incurs an additional memory allocation when you | 185 // Also note that this incurs an additional memory allocation when you |
| 186 // create an Immutable<SomeOtherType>. | 186 // create an Immutable<SomeOtherType>. |
| 187 | 187 |
| 188 template <typename T> | 188 template <typename T> |
| 189 struct DefaultImmutableTraits { | 189 struct DefaultImmutableTraits { |
| 190 typedef T Wrapper; | 190 using Wrapper = T; |
| 191 | 191 |
| 192 static void InitializeWrapper(Wrapper* wrapper) {} | 192 static void InitializeWrapper(Wrapper* wrapper) {} |
| 193 | 193 |
| 194 static void DestroyWrapper(Wrapper* wrapper) {} | 194 static void DestroyWrapper(Wrapper* wrapper) {} |
| 195 | 195 |
| 196 static const T& Unwrap(const Wrapper& wrapper) { return wrapper; } | 196 static const T& Unwrap(const Wrapper& wrapper) { return wrapper; } |
| 197 | 197 |
| 198 static T* UnwrapMutable(Wrapper* wrapper) { return wrapper; } | 198 static T* UnwrapMutable(Wrapper* wrapper) { return wrapper; } |
| 199 | 199 |
| 200 static void Swap(T* t1, T* t2) { | 200 static void Swap(T* t1, T* t2) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 | 238 |
| 239 // Helper function to avoid having to write out template arguments. | 239 // Helper function to avoid having to write out template arguments. |
| 240 template <typename T> | 240 template <typename T> |
| 241 Immutable<T> MakeImmutable(T* t) { | 241 Immutable<T> MakeImmutable(T* t) { |
| 242 return Immutable<T>(t); | 242 return Immutable<T>(t); |
| 243 } | 243 } |
| 244 | 244 |
| 245 } // namespace syncer | 245 } // namespace syncer |
| 246 | 246 |
| 247 #endif // COMPONENTS_SYNC_BASE_IMMUTABLE_H_ | 247 #endif // COMPONENTS_SYNC_BASE_IMMUTABLE_H_ |
| OLD | NEW |