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

Unified Diff: base/memory/singleton.h

Issue 2932053002: Use C++11 alignment primitives (Closed)
Patch Set: Fixes 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
Index: base/memory/singleton.h
diff --git a/base/memory/singleton.h b/base/memory/singleton.h
index 5c58d5fe2944cd332980fb39f5dc5e815a48c0d4..2f19f6cc3036ab154c6e4605601bca82359c0ed7 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_;
+ static alignas(Type) 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;

Powered by Google App Engine
This is Rietveld 408576698