Chromium Code Reviews| Index: base/memory/manual_constructor.h |
| diff --git a/base/memory/manual_constructor.h b/base/memory/manual_constructor.h |
| index 9275f73b83b80e74ad9144d40094f7038ac58d5b..a9f0b4a73c82be80fc9cb95215cf79777835cef3 100644 |
| --- a/base/memory/manual_constructor.h |
| +++ b/base/memory/manual_constructor.h |
| @@ -18,6 +18,7 @@ |
| #include <stddef.h> |
| +#include "base/compiler_specific.h" |
| #include "base/memory/aligned_memory.h" |
| namespace base { |
| @@ -33,11 +34,7 @@ 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) { |
| -#if defined(COMPILER_MSVC) |
| - return AlignedAlloc(size, __alignof(Type)); |
| -#else |
| - return AlignedAlloc(size, __alignof__(Type)); |
| -#endif |
| + return AlignedAlloc(size, ALIGNOF(Type)); |
| } |
| static void operator delete[](void* mem) { |
| AlignedFree(mem); |
| @@ -57,55 +54,9 @@ class ManualConstructor { |
| inline const Type& operator*() const { return *get(); } |
| // You can pass up to eight constructor arguments as arguments of Init(). |
|
Nico
2015/04/08 17:37:16
Remove this comment, it's no longer true.
|
| - inline void Init() { |
| - new(space_.void_data()) Type; |
| - } |
| - |
| - template <typename T1> |
| - inline void Init(const T1& p1) { |
| - new(space_.void_data()) Type(p1); |
| - } |
| - |
| - template <typename T1, typename T2> |
| - inline void Init(const T1& p1, const T2& p2) { |
| - new(space_.void_data()) Type(p1, p2); |
| - } |
| - |
| - template <typename T1, typename T2, typename T3> |
| - inline void Init(const T1& p1, const T2& p2, const T3& p3) { |
| - new(space_.void_data()) Type(p1, p2, p3); |
| - } |
| - |
| - template <typename T1, typename T2, typename T3, typename T4> |
| - inline void Init(const T1& p1, const T2& p2, const T3& p3, const T4& p4) { |
| - new(space_.void_data()) Type(p1, p2, p3, p4); |
| - } |
| - |
| - template <typename T1, typename T2, typename T3, typename T4, typename T5> |
| - inline void Init(const T1& p1, const T2& p2, const T3& p3, const T4& p4, |
| - const T5& p5) { |
| - new(space_.void_data()) Type(p1, p2, p3, p4, p5); |
| - } |
| - |
| - template <typename T1, typename T2, typename T3, typename T4, typename T5, |
| - typename T6> |
| - inline void Init(const T1& p1, const T2& p2, const T3& p3, const T4& p4, |
| - const T5& p5, const T6& p6) { |
| - new(space_.void_data()) Type(p1, p2, p3, p4, p5, p6); |
| - } |
| - |
| - template <typename T1, typename T2, typename T3, typename T4, typename T5, |
| - typename T6, typename T7> |
| - inline void Init(const T1& p1, const T2& p2, const T3& p3, const T4& p4, |
| - const T5& p5, const T6& p6, const T7& p7) { |
| - new(space_.void_data()) Type(p1, p2, p3, p4, p5, p6, p7); |
| - } |
| - |
| - template <typename T1, typename T2, typename T3, typename T4, typename T5, |
| - typename T6, typename T7, typename T8> |
| - inline void Init(const T1& p1, const T2& p2, const T3& p3, const T4& p4, |
| - const T5& p5, const T6& p6, const T7& p7, const T8& p8) { |
| - new(space_.void_data()) Type(p1, p2, p3, p4, p5, p6, p7, p8); |
| + template <typename... Ts> |
| + inline void Init(const Ts&... params) { |
| + new(space_.void_data()) Type(params...); |
| } |
| inline void Destroy() { |
| @@ -113,11 +64,7 @@ class ManualConstructor { |
| } |
| private: |
| -#if defined(COMPILER_MSVC) |
| - AlignedMemory<sizeof(Type), __alignof(Type)> space_; |
| -#else |
| - AlignedMemory<sizeof(Type), __alignof__(Type)> space_; |
| -#endif |
| + AlignedMemory<sizeof(Type), ALIGNOF(Type)> space_; |
| }; |
| } // namespace base |