44 typedef std::size_t size_type;
45 typedef std::ptrdiff_t difference_type;
60 const_pointer address(const_reference value)
const {
61 return std::addressof(value);
64 pointer address(reference value)
const {
65 return std::addressof(value);
68 pointer allocate(size_type size,
const void* =
nullptr) {
69 void* p = aligned_alloc(alignment,
sizeof(T) * size);
71 throw nn_error(
"failed to allocate");
72 return static_cast<pointer
>(p);
75 size_type max_size()
const {
76 return ~static_cast<std::size_t>(0) /
sizeof(T);
79 void deallocate(pointer ptr, size_type) {
83 template<
class U,
class V>
84 void construct(U* ptr,
const V& value) {
89#if defined(_MSC_VER) && _MSC_VER <= 1800
92 template<
class U,
class... Args>
93 void construct(U* ptr, Args&&... args) {
95 ::new(p) U(std::forward<Args>(args)...);
100 void construct(U* ptr) {
106 void destroy(U* ptr) {
111 void* aligned_alloc(size_type align, size_type size)
const {
113 return ::_aligned_malloc(size, align);
114#elif defined (__ANDROID__)
115 return ::memalign(align, size);
116#elif defined (__MINGW32__)
117 return ::_mm_malloc(size, align);
120 if (::posix_memalign(&p, align, size) != 0) {
127 void aligned_free(pointer ptr) {
129 ::_aligned_free(ptr);
130#elif defined(__MINGW32__)
139inline bool operator==(
const aligned_allocator<T1, alignment>&,
const aligned_allocator<T2, alignment>&)
145inline bool operator!=(
const aligned_allocator<T1, alignment>&,
const aligned_allocator<T2, alignment>&)