Fix AlignedAllocator for pre-C++11 libraries

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1511233002 .
This commit is contained in:
Mark Mentovai 2015-12-09 17:25:05 -05:00
Родитель e9a843c626
Коммит a33736dd0d
1 изменённых файлов: 11 добавлений и 2 удалений

Просмотреть файл

@ -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) {