7 #include "cAudioDefines.h"
8 #include "cAudioMemory.h"
20 #if CAUDIO_REROUTE_STL_ALLOCATIONS == 1
21 template <
typename T>
class cSTLAllocator
26 typedef value_type* pointer;
27 typedef const value_type* const_pointer;
28 typedef value_type& reference;
29 typedef const value_type& const_reference;
30 typedef std::size_t size_type;
31 typedef std::ptrdiff_t difference_type;
36 typedef cSTLAllocator<U> other;
42 ~cSTLAllocator() throw()
45 cSTLAllocator(
const cSTLAllocator& )
throw()
49 cSTLAllocator(
const cSTLAllocator<U>& )
throw()
52 pointer address(reference x)
const
57 const_pointer address(const_reference x)
const
62 pointer allocate( size_type count,
typename std::allocator<void>::const_pointer ptr = 0 )
65 size_type size = count*
sizeof( T );
66 pointer p =
static_cast<pointer
>(CAUDIO_MALLOC(size));
70 void deallocate( pointer p, size_type size )
75 size_type max_size()
const throw()
80 void construct(pointer p,
const T& val)
83 new(
static_cast<void*
>(p)) T(val);
86 void destroy(pointer p)
92 template<>
class cSTLAllocator<void>
95 typedef size_t size_type;
96 typedef ptrdiff_t difference_type;
97 typedef void* pointer;
98 typedef const void* const_pointer;
99 typedef void value_type;
104 typedef cSTLAllocator<U> other;
108 template <
typename T>
109 inline bool operator==(
const cSTLAllocator<T>&,
const cSTLAllocator<T>&)
114 template <
typename T>
115 inline bool operator!=(
const cSTLAllocator<T>&,
const cSTLAllocator<T>&)
121 #if CAUDIO_REROUTE_STL_ALLOCATIONS == 1
123 template<
typename T1,
typename T2>
struct cAudioMap {
typedef std::map< T1, T2, std::less< T1 >, cSTLAllocator< std::pair< T1, T2 > > > Type; };
124 template<
typename T>
struct cAudioSet {
typedef std::set< T, std::less< T >, cSTLAllocator< T > > Type; };
125 template<
typename T>
struct cAudioList {
typedef std::list< T, cSTLAllocator< T > > Type; };
126 template<
typename T>
struct cAudioVector {
typedef std::vector< T, cSTLAllocator< T > > Type; };
130 template<
typename T1,
typename T2>
struct cAudioMap {
typedef std::map< T1, T2> Type; };
131 template<
typename T>
struct cAudioSet {
typedef std::set< T > Type; };
132 template<
typename T>
struct cAudioList {
typedef std::list< T > Type; };
133 template<
typename T>
struct cAudioVector {
typedef std::vector< T > Type; };