Index: base/memory/manual_constructor.h |
diff --git a/base/memory/manual_constructor.h b/base/memory/manual_constructor.h |
index 9275f73b83b80e74ad9144d40094f7038ac58d5b..56081a1d3bc5362a6797a2aeca2d2516f74689f6 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); |
@@ -56,56 +53,9 @@ class ManualConstructor { |
inline Type& operator*() { return *get(); } |
inline const Type& operator*() const { return *get(); } |
- // You can pass up to eight constructor arguments as arguments of Init(). |
- 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 +63,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 |