Index: base/memory/manual_constructor.h |
diff --git a/base/memory/manual_constructor.h b/base/memory/manual_constructor.h |
index f401f62d513803803efdd4de3a8b1de8ede9ba9f..26a9e4ed9c1aa5a82af2b0e24191ac9978e56bbb 100644 |
--- a/base/memory/manual_constructor.h |
+++ b/base/memory/manual_constructor.h |
@@ -17,6 +17,7 @@ |
#define BASE_MEMORY_MANUAL_CONSTRUCTOR_H_ |
#include <stddef.h> |
+#include <type_traits> |
#include "base/compiler_specific.h" |
#include "base/memory/aligned_memory.h" |
@@ -34,17 +35,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 +54,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 +66,7 @@ class ManualConstructor { |
} |
private: |
- AlignedMemory<sizeof(Type), ALIGNOF(Type)> space_; |
+ typename std::aligned_storage<sizeof(Type), alignof(Type)>::type space_; |
}; |
} // namespace base |