14 #ifndef STXXL_NEW_ALLOC_HEADER
15 #define STXXL_NEW_ALLOC_HEADER
19 #include <stxxl/bits/namespace.h>
22 __STXXL_BEGIN_NAMESPACE
27 template <
typename T,
typename U>
28 struct new_alloc_rebind;
31 struct new_alloc_rebind<T, T>{
32 typedef new_alloc<T> other;
35 template <
typename T,
typename U>
36 struct new_alloc_rebind {
37 typedef std::allocator<U> other;
48 typedef const T * const_pointer;
49 typedef T & reference;
50 typedef const T & const_reference;
51 typedef std::size_t size_type;
52 typedef std::ptrdiff_t difference_type;
57 typedef typename new_alloc_rebind<T, U>::other other;
61 pointer address(reference value)
const
65 const_pointer address(const_reference value)
const
70 new_alloc() throw () { }
71 new_alloc(
const new_alloc &) throw () { }
73 new_alloc(
const new_alloc<U> &) throw () { }
74 ~new_alloc() throw () { }
77 operator std::allocator<U>()
79 static std::allocator<U> helper_allocator;
80 return helper_allocator;
84 size_type max_size()
const throw ()
86 return (std::numeric_limits<size_type>::max)() /
sizeof(T);
90 pointer allocate(size_type num,
const void * = 0)
92 return static_cast<T *
>(T::operator
new (num *
sizeof(T)));
98 void construct(pointer p,
const T & value)
101 ::new ((
void *)p)T(value);
104 #ifdef __GXX_EXPERIMENTAL_CXX0X__
105 template <
typename ... Args>
106 void construct(pointer p, Args && ... args)
108 ::new ((
void *)p)T(std::forward<Args>(args) ...);
113 void destroy(pointer p)
120 void deallocate(pointer p, size_type )
122 T::operator
delete (p);
127 template <
class T1,
class T2>
128 inline bool operator == (
const new_alloc<T1> &,
129 const new_alloc<T2> &) throw ()
134 template <
class T1,
class T2>
135 inline bool operator != (
const new_alloc<T1> &,
136 const new_alloc<T2> &) throw ()
141 __STXXL_END_NAMESPACE
143 #endif // !STXXL_NEW_ALLOC_HEADER