1 #ifndef CARMA_UTIL_MP_ALLOCATOR_H
2 #define CARMA_UTIL_MP_ALLOCATOR_H
12 class MpRawAllocator {
14 static void * alloc( ::std::size_t bytes );
15 static void dealloc(
void * p, ::std::size_t bytes );
19 template <
typename T >
25 typedef const T * const_pointer;
27 typedef const T & const_reference;
28 typedef ::std::size_t size_type;
29 typedef ::std::ptrdiff_t difference_type;
32 template <
typename U >
34 typedef MpAllocator< U > other;
38 pointer address( reference value )
const {
42 const_pointer address( const_reference value )
const {
49 MpAllocator( ) throw( ) { }
51 MpAllocator(
const MpAllocator & rhs )
throw( ) { }
53 template <
typename U >
54 MpAllocator(
const MpAllocator< U > & rhs )
throw( ) { }
56 ~MpAllocator( ) throw( ) { }
59 size_type max_size ( )
const throw( ) {
60 return (::std::numeric_limits< ::std::size_t >::max( ) /
sizeof( T ));
64 pointer allocate( size_type num,
65 const void * dummy = 0 ) {
66 return static_cast< pointer
>( MpRawAllocator::alloc( num *
sizeof( T ) ) );
70 void construct( pointer p,
73 new (
static_cast< void *
>( p )) T( value );
77 void destroy( pointer p ) {
83 void deallocate( pointer p,
85 MpRawAllocator::dealloc( static_cast< void * >( p ), (num *
sizeof( T )) );
92 template <
typename T1,
typename T2 >
94 operator==(
const MpAllocator< T1 > & lhs,
const MpAllocator< T2 > & rhs )
throw( ) {
99 template <
typename T1,
typename T2 >
101 operator!=(
const MpAllocator< T1 > & lhs,
const MpAllocator< T2 > & rhs )
throw( ) {