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

Unified Diff: util/stdlib/aligned_allocator.h

Issue 1511233002: Fix AlignedAllocator for pre-C++11 libraries (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/stdlib/aligned_allocator.h
diff --git a/util/stdlib/aligned_allocator.h b/util/stdlib/aligned_allocator.h
index 38ecf617e0241f6d5a62a82e02f6c0fb65fafeff..04d3dc46cd279031ad55a6641fa03bccc842581f 100644
--- a/util/stdlib/aligned_allocator.h
+++ b/util/stdlib/aligned_allocator.h
@@ -25,6 +25,7 @@
#include "base/compiler_specific.h"
#include "build/build_config.h"
+#include "util/stdlib/cxx.h"
#if defined(COMPILER_MSVC) && _MSC_VER < 1900
#define CRASHPAD_NOEXCEPT _NOEXCEPT
@@ -79,8 +80,10 @@ struct AlignedAllocator {
~AlignedAllocator() {}
- pointer address(reference x) CRASHPAD_NOEXCEPT { return &x; }
- const_pointer address(const_reference x) CRASHPAD_NOEXCEPT { return &x; }
+ pointer address(reference x) const CRASHPAD_NOEXCEPT { return &x; }
+ const_pointer address(const_reference x) const CRASHPAD_NOEXCEPT {
+ return &x;
+ }
pointer allocate(size_type n, std::allocator<void>::const_pointer hint = 0) {
return reinterpret_cast<pointer>(
@@ -93,10 +96,16 @@ struct AlignedAllocator {
return std::numeric_limits<size_type>::max() / sizeof(value_type);
}
+#if CXX_LIBRARY_VERSION < 2011
+ void construct(pointer p, const T& val) {
+ new (reinterpret_cast<void*>(p)) T(val);
+ }
+#else
template <class U, class... Args>
void construct(U* p, Args&&... args) {
new (reinterpret_cast<void*>(p)) U(std::forward<Args>(args)...);
}
+#endif
template <class U>
void destroy(U* p) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698