30 #ifndef _CEGUIMemorySTLWrapper_h_
31 #define _CEGUIMemorySTLWrapper_h_
33 #ifndef _CEGUIMemoryAllocation_h_
34 # error Dont include this directly! Include CEGUIBase.h instead.
40 #ifdef CEGUI_CUSTOM_ALLOCATORS
43 struct STLAllocatorWrapperBase
49 struct STLAllocatorWrapperBase<const T>
54 template <
typename T,
typename Allocator>
55 class STLAllocatorWrapper :
public STLAllocatorWrapperBase<T>
58 typedef STLAllocatorWrapperBase<T> Base;
59 typedef typename Base::value_type value_type;
61 typedef value_type* pointer;
62 typedef const value_type* const_pointer;
63 typedef value_type& reference;
64 typedef const value_type& const_reference;
66 typedef std::size_t size_type;
67 typedef std::ptrdiff_t difference_type;
72 typedef STLAllocatorWrapper<U, Allocator> other;
75 inline explicit STLAllocatorWrapper()
78 inline STLAllocatorWrapper(
const STLAllocatorWrapper&)
81 template <
typename U,
typename P>
82 inline STLAllocatorWrapper(
const STLAllocatorWrapper<U, P>&)
85 inline pointer address(reference x)
const
90 inline const_pointer address(const_reference x)
const
95 inline size_type max_size()
const throw()
97 return Allocator::getMaxAllocationSize();
100 inline pointer allocate(size_type count,
typename std::allocator<void>::const_pointer ptr = 0)
103 return static_cast<pointer
>(Allocator::allocateBytes(count *
sizeof(T)));
106 inline void deallocate(pointer ptr, size_type )
108 Allocator::deallocateBytes(ptr);
111 inline void construct(pointer p,
const T& val)
113 new(
static_cast<void*
>(p)) T(val);
116 inline void destroy(pointer p)
122 template<
typename T,
typename T2,
typename P>
123 inline bool operator==(
const STLAllocatorWrapper<T, P>&,
const STLAllocatorWrapper<T2, P>&)
129 template<
typename T,
typename P,
typename OtherAllocator>
130 inline bool operator==(
const STLAllocatorWrapper<T, P>&,
const OtherAllocator&)
136 template<
typename T,
typename T2,
typename P>
137 inline bool operator!=(
const STLAllocatorWrapper<T, P>&,
const STLAllocatorWrapper<T2,P>&)
143 template<
typename T,
typename P,
typename OtherAllocator>
144 inline bool operator!=(
const STLAllocatorWrapper<T, P>&,
const OtherAllocator&)
151 #define CEGUI_VECTOR_ALLOC(T) , ::CEGUI::STLAllocatorWrapper<T, ::CEGUI::AllocatorConfig< ::CEGUI::STLAllocator >::Allocator>
152 #define CEGUI_SET_ALLOC(T) , ::CEGUI::STLAllocatorWrapper<T, ::CEGUI::AllocatorConfig< ::CEGUI::STLAllocator >::Allocator>
153 #define CEGUI_MAP_ALLOC(K, V) , ::CEGUI::STLAllocatorWrapper<std::pair<K, V>, ::CEGUI::AllocatorConfig< ::CEGUI::STLAllocator >::Allocator>
154 #define CEGUI_MULTIMAP_ALLOC(K, V) , ::CEGUI::STLAllocatorWrapper<std::pair<K, V>, ::CEGUI::AllocatorConfig< ::CEGUI::STLAllocator >::Allocator>
159 #define CEGUI_VECTOR_ALLOC(T)
160 #define CEGUI_SET_ALLOC(T)
161 #define CEGUI_MAP_ALLOC(K, V)
162 #define CEGUI_MULTIMAP_ALLOC(K, V)
168 #endif // end of guard _CEGUIMemorySTLWrapper_h_