29 #ifndef _CEGUIMemorySTLWrapper_h_
30 #define _CEGUIMemorySTLWrapper_h_
32 #ifndef _CEGUIMemoryAllocation_h_
33 # error Dont include this directly! Include CEGUIBase.h instead.
39 #ifdef CEGUI_CUSTOM_ALLOCATORS
42 struct STLAllocatorWrapperBase
48 struct STLAllocatorWrapperBase<const T>
53 template <
typename T,
typename Allocator>
54 class STLAllocatorWrapper :
public STLAllocatorWrapperBase<T>
57 typedef STLAllocatorWrapperBase<T> Base;
58 typedef typename Base::value_type value_type;
60 typedef value_type* pointer;
61 typedef const value_type* const_pointer;
62 typedef value_type& reference;
63 typedef const value_type& const_reference;
65 typedef std::size_t size_type;
66 typedef std::ptrdiff_t difference_type;
71 typedef STLAllocatorWrapper<U, Allocator> other;
74 inline explicit STLAllocatorWrapper()
77 inline STLAllocatorWrapper(
const STLAllocatorWrapper&)
80 template <
typename U,
typename P>
81 inline STLAllocatorWrapper(
const STLAllocatorWrapper<U, P>&)
84 inline pointer address(reference x)
const
89 inline const_pointer address(const_reference x)
const
94 inline size_type max_size()
const throw()
96 return Allocator::getMaxAllocationSize();
99 inline pointer allocate(size_type count,
typename std::allocator<void>::const_pointer ptr = 0)
102 return static_cast<pointer
>(Allocator::allocateBytes(count *
sizeof(T)));
105 inline void deallocate(pointer ptr, size_type )
107 Allocator::deallocateBytes(ptr);
110 inline void construct(pointer p,
const T& val)
112 new(
static_cast<void*
>(p)) T(val);
115 inline void destroy(pointer p)
121 template<
typename T,
typename T2,
typename P>
122 inline bool operator==(
const STLAllocatorWrapper<T, P>&,
const STLAllocatorWrapper<T2, P>&)
128 template<
typename T,
typename P,
typename OtherAllocator>
129 inline bool operator==(
const STLAllocatorWrapper<T, P>&,
const OtherAllocator&)
135 template<
typename T,
typename T2,
typename P>
136 inline bool operator!=(
const STLAllocatorWrapper<T, P>&,
const STLAllocatorWrapper<T2,P>&)
142 template<
typename T,
typename P,
typename OtherAllocator>
143 inline bool operator!=(
const STLAllocatorWrapper<T, P>&,
const OtherAllocator&)
150 #define CEGUI_VECTOR_ALLOC(T) , ::CEGUI::STLAllocatorWrapper<T, ::CEGUI::AllocatorConfig< ::CEGUI::STLAllocator >::Allocator>
151 #define CEGUI_SET_ALLOC(T) , ::CEGUI::STLAllocatorWrapper<T, ::CEGUI::AllocatorConfig< ::CEGUI::STLAllocator >::Allocator>
152 #define CEGUI_MAP_ALLOC(K, V) , ::CEGUI::STLAllocatorWrapper<std::pair<K, V>, ::CEGUI::AllocatorConfig< ::CEGUI::STLAllocator >::Allocator>
153 #define CEGUI_MULTIMAP_ALLOC(K, V) , ::CEGUI::STLAllocatorWrapper<std::pair<K, V>, ::CEGUI::AllocatorConfig< ::CEGUI::STLAllocator >::Allocator>
158 #define CEGUI_VECTOR_ALLOC(T)
159 #define CEGUI_SET_ALLOC(T)
160 #define CEGUI_MAP_ALLOC(K, V)
161 #define CEGUI_MULTIMAP_ALLOC(K, V)
167 #endif // end of guard _CEGUIMemorySTLWrapper_h_