Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Unified Diff: base/memory/manual_constructor.h

Issue 2932053002: Use C++11 alignment primitives (Closed)
Patch Set: Fix merge Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/memory/aligned_memory_unittest.cc ('k') | base/memory/singleton.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/manual_constructor.h
diff --git a/base/memory/manual_constructor.h b/base/memory/manual_constructor.h
index f401f62d513803803efdd4de3a8b1de8ede9ba9f..e968d04312227506f42e1040da3813a6da24cf14 100644
--- a/base/memory/manual_constructor.h
+++ b/base/memory/manual_constructor.h
@@ -34,17 +34,15 @@ class ManualConstructor {
// Support users creating arrays of ManualConstructor<>s. This ensures that
// the array itself has the correct alignment.
static void* operator new[](size_t size) {
- return AlignedAlloc(size, ALIGNOF(Type));
+ return AlignedAlloc(size, alignof(Type));
}
static void operator delete[](void* mem) {
AlignedFree(mem);
}
- inline Type* get() {
- return space_.template data_as<Type>();
- }
+ inline Type* get() { return reinterpret_cast<Type*>(space_); }
inline const Type* get() const {
- return space_.template data_as<Type>();
+ return reinterpret_cast<const Type*>(space_);
}
inline Type* operator->() { return get(); }
@@ -55,7 +53,7 @@ class ManualConstructor {
template <typename... Ts>
inline void Init(Ts&&... params) {
- new(space_.void_data()) Type(std::forward<Ts>(params)...);
+ new (space_) Type(std::forward<Ts>(params)...);
}
inline void InitFromMove(ManualConstructor<Type>&& o) {
@@ -67,7 +65,7 @@ class ManualConstructor {
}
private:
- AlignedMemory<sizeof(Type), ALIGNOF(Type)> space_;
+ alignas(Type) char space_[sizeof(Type)];
};
} // namespace base
« no previous file with comments | « base/memory/aligned_memory_unittest.cc ('k') | base/memory/singleton.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698