CAD Exchanger SDK
cadex::Base_Allocator< T > Class Template Reference

Implements allocator requirements as defined in ISO C++ Standard 2003, section 20.1.5. More...

Public Types

typedef T value_type
 Defines a value type.
 
typedef value_typepointer
 Defines a value pointer type.
 
typedef const value_typeconst_pointer
 Defines a const value pointer type.
 
typedef value_typereference
 Defines a value reference type.
 
typedef const value_typeconst_reference
 Defines a const value reference type.
 
typedef size_t size_type
 Defines a size type.
 
typedef ptrdiff_t difference_type
 Defines a pointer difference type.
 

Public Member Functions

 Base_Allocator () throw ()
 Constructor. More...
 
 Base_Allocator (const Base_Allocator &) throw ()
 Constructor. More...
 
 ~Base_Allocator () throw ()
 Destructor. More...
 
template<typename U >
 Base_Allocator (const Base_Allocator< U > &) throw ()
 Constructor. More...
 
pointer address (reference x) const
 Returns an object address. More...
 
const_pointer address (const_reference x) const
 Returns an object address. More...
 
pointer allocate (size_type n, const void *=0)
 Allocates memory for n objects. More...
 
void deallocate (pointer p, size_type)
 Frees previously allocated memory. More...
 
size_type max_size () const throw ()
 Returns the largest value for which method allocate might succeed.
 
void construct (pointer p, const_reference val)
 Constructs an object. More...
 
void construct (pointer p, T &&val)
 Constructs an object. More...
 
template<typename U >
void construct (pointer p, U &&val)
 Constructs an object. More...
 
void destroy (pointer p)
 Destroys the object. More...
 

Detailed Description

template<typename T>
class cadex::Base_Allocator< T >

Implements allocator requirements as defined in ISO C++ Standard 2003, section 20.1.5.

The allocator uses cadex_alloc(), cadex_free(). The allocator can be used with standard containers (std::vector, std::map, etc) to take advantage of CAD Exchanger allocator.

Example of use:

std::list<int, Base_Allocator<int> > aL;
aL.push_back (0);

Constructor & Destructor Documentation

◆ Base_Allocator() [1/3]

template<typename T >
cadex::Base_Allocator< T >::Base_Allocator ( )
throw (
)
inline

Constructor.

Empty constructor.

◆ Base_Allocator() [2/3]

template<typename T >
cadex::Base_Allocator< T >::Base_Allocator ( const Base_Allocator< T > &  )
throw (
)
inline

Constructor.

Empty constructor.

◆ ~Base_Allocator()

template<typename T >
cadex::Base_Allocator< T >::~Base_Allocator ( )
throw (
)
inline

Destructor.

Empty implementation.

◆ Base_Allocator() [3/3]

template<typename T >
template<typename U >
cadex::Base_Allocator< T >::Base_Allocator ( const Base_Allocator< U > &  )
throw (
)
inline

Constructor.

Empty constructor.

Member Function Documentation

◆ address() [1/2]

template<typename T >
pointer cadex::Base_Allocator< T >::address ( reference  x) const
inline

Returns an object address.

Returns &x.

◆ address() [2/2]

template<typename T >
const_pointer cadex::Base_Allocator< T >::address ( const_reference  x) const
inline

Returns an object address.

Returns &x.

◆ allocate()

template<typename T >
pointer cadex::Base_Allocator< T >::allocate ( size_type  n,
const void *  = 0 
)
inline

Allocates memory for n objects.

Uses underlying allocator to allocate memory.

◆ construct() [1/3]

template<typename T >
void cadex::Base_Allocator< T >::construct ( pointer  p,
const_reference  val 
)
inline

Constructs an object.

Uses placement new operator and copy constructor to construct an object.

◆ construct() [2/3]

template<typename T >
void cadex::Base_Allocator< T >::construct ( pointer  p,
T &&  val 
)
inline

Constructs an object.

Uses placement new operator and move constructor to construct an object.

◆ construct() [3/3]

template<typename T >
template<typename U >
void cadex::Base_Allocator< T >::construct ( pointer  p,
U &&  val 
)
inline

Constructs an object.

Uses placement new operator and universal constructor to construct an object.

◆ deallocate()

template<typename T >
void cadex::Base_Allocator< T >::deallocate ( pointer  p,
size_type   
)
inline

Frees previously allocated memory.

Uses underlying allocator to deallocate memory.

◆ destroy()

template<typename T >
void cadex::Base_Allocator< T >::destroy ( pointer  p)
inline

Destroys the object.

Uses object destructor.