8 template <
class T,
int N>
13 typedef const T& const_reference;
15 typedef const T* const_pointer;
16 typedef size_t size_type;
17 typedef ptrdiff_t difference_type;
28 inline aligned_allocator(
const aligned_allocator<U,N>&)
throw() {}
29 inline ~aligned_allocator() throw() {}
31 inline pointer address(reference r) {
return &r; }
32 inline const_pointer address(const_reference r)
const {
return &r; }
34 pointer allocate(size_type n,
typename std::allocator<void>::const_pointer hint = 0);
35 inline void deallocate(pointer p, size_type);
37 inline void construct(pointer p, const_reference value) {
new (p) value_type(value); }
38 inline void destroy(pointer p) { p->~value_type(); }
40 inline size_type max_size()
const throw() {
return size_type(-1) /
sizeof(T); }
42 inline bool operator==(
const aligned_allocator&) {
return true; }
43 inline bool operator!=(
const aligned_allocator& rhs) {
return !operator==(rhs); }
46 template <
class T,
int N>
47 typename aligned_allocator<T, N>::pointer
48 aligned_allocator<T, N>::allocate(size_type n,
typename std::allocator<void>::const_pointer hint) {
51 pointer res =
reinterpret_cast<pointer
>(aligned_alloc(N,
sizeof(T) * n));
53 throw std::bad_alloc();
57 template <
class T,
int N>
58 void aligned_allocator<T, N>::deallocate(pointer p, size_type) {