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

Unified Diff: base/memory/singleton.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/manual_constructor.h ('k') | base/memory/singleton_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/singleton.h
diff --git a/base/memory/singleton.h b/base/memory/singleton.h
index 5c58d5fe2944cd332980fb39f5dc5e815a48c0d4..d604910024018fe9f980a1b83f99e094570c558e 100644
--- a/base/memory/singleton.h
+++ b/base/memory/singleton.h
@@ -24,7 +24,6 @@
#include "base/base_export.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/aligned_memory.h"
#include "base/threading/thread_restrictions.h"
namespace base {
@@ -115,7 +114,7 @@ struct StaticMemorySingletonTraits {
if (subtle::NoBarrier_AtomicExchange(&dead_, 1))
return NULL;
- return new(buffer_.void_data()) Type();
+ return new (buffer_) Type();
}
static void Delete(Type* p) {
@@ -130,14 +129,13 @@ struct StaticMemorySingletonTraits {
static void Resurrect() { subtle::NoBarrier_Store(&dead_, 0); }
private:
- static AlignedMemory<sizeof(Type), ALIGNOF(Type)> buffer_;
+ alignas(Type) static char buffer_[sizeof(Type)];
// Signal the object was already deleted, so it is not revived.
static subtle::Atomic32 dead_;
};
template <typename Type>
-AlignedMemory<sizeof(Type), ALIGNOF(Type)>
- StaticMemorySingletonTraits<Type>::buffer_;
+alignas(Type) char StaticMemorySingletonTraits<Type>::buffer_[sizeof(Type)];
template <typename Type>
subtle::Atomic32 StaticMemorySingletonTraits<Type>::dead_ = 0;
« no previous file with comments | « base/memory/manual_constructor.h ('k') | base/memory/singleton_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698