From a33736dd0d6060f451daad98bd7073f12c13dafe Mon Sep 17 00:00:00 2001 From: Mark Mentovai Date: Wed, 9 Dec 2015 17:25:05 -0500 Subject: [PATCH] Fix AlignedAllocator for pre-C++11 libraries R=scottmg@chromium.org Review URL: https://codereview.chromium.org/1511233002 . --- util/stdlib/aligned_allocator.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/util/stdlib/aligned_allocator.h b/util/stdlib/aligned_allocator.h index 38ecf61..04d3dc4 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::const_pointer hint = 0) { return reinterpret_cast( @@ -93,10 +96,16 @@ struct AlignedAllocator { return std::numeric_limits::max() / sizeof(value_type); } +#if CXX_LIBRARY_VERSION < 2011 + void construct(pointer p, const T& val) { + new (reinterpret_cast(p)) T(val); + } +#else template void construct(U* p, Args&&... args) { new (reinterpret_cast(p)) U(std::forward(args)...); } +#endif template void destroy(U* p) {