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

Unified Diff: base/containers/stack_container.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/compiler_specific.h ('k') | base/containers/stack_container_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/containers/stack_container.h
diff --git a/base/containers/stack_container.h b/base/containers/stack_container.h
index 5090aaff3eae78f4392fcdc6df5e3d6a88c2ced5..c7757443052a52735aa7eff207183d6a1645995d 100644
--- a/base/containers/stack_container.h
+++ b/base/containers/stack_container.h
@@ -10,7 +10,6 @@
#include <vector>
#include "base/macros.h"
-#include "base/memory/aligned_memory.h"
#include "build/build_config.h"
namespace base {
@@ -47,17 +46,17 @@ class StackAllocator : public std::allocator<T> {
}
// Casts the buffer in its right type.
- T* stack_buffer() { return stack_buffer_.template data_as<T>(); }
+ T* stack_buffer() { return reinterpret_cast<T*>(stack_buffer_); }
const T* stack_buffer() const {
- return stack_buffer_.template data_as<T>();
+ return reinterpret_cast<const T*>(&stack_buffer_);
}
// The buffer itself. It is not of type T because we don't want the
// constructors and destructors to be automatically called. Define a POD
// buffer of the right size instead.
- base::AlignedMemory<sizeof(T[stack_capacity]), ALIGNOF(T)> stack_buffer_;
+ alignas(T) char stack_buffer_[sizeof(T[stack_capacity])];
#if defined(__GNUC__) && !defined(ARCH_CPU_X86_FAMILY)
- static_assert(ALIGNOF(T) <= 16, "http://crbug.com/115612");
+ static_assert(alignof(T) <= 16, "http://crbug.com/115612");
#endif
// Set when the stack buffer is used for an allocation. We do not track
« no previous file with comments | « base/compiler_specific.h ('k') | base/containers/stack_container_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698