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

Unified Diff: base/memory/singleton.h

Issue 2932053002: Use C++11 alignment primitives (Closed)
Patch Set: Put back ALIGNAS 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..568c457266f616d4bac14167e0bea42be73e13d0 100644
--- a/base/memory/singleton.h
+++ b/base/memory/singleton.h
@@ -19,12 +19,13 @@
#ifndef BASE_MEMORY_SINGLETON_H_
#define BASE_MEMORY_SINGLETON_H_
+#include <type_traits>
+
#include "base/at_exit.h"
#include "base/atomicops.h"
#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 +116,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,13 +131,14 @@ struct StaticMemorySingletonTraits {
static void Resurrect() { subtle::NoBarrier_Store(&dead_, 0); }
private:
- static AlignedMemory<sizeof(Type), ALIGNOF(Type)> buffer_;
+ static
+ typename std::aligned_storage<sizeof(Type), alignof(Type)>::type buffer_;
// Signal the object was already deleted, so it is not revived.
static subtle::Atomic32 dead_;
};
template <typename Type>
-AlignedMemory<sizeof(Type), ALIGNOF(Type)>
+typename std::aligned_storage<sizeof(Type), alignof(Type)>::type
StaticMemorySingletonTraits<Type>::buffer_;
template <typename Type>
subtle::Atomic32 StaticMemorySingletonTraits<Type>::dead_ = 0;

Powered by Google App Engine
This is Rietveld 408576698