neuray API Programmer's Manual

mi::base::Std_allocator< T> Template Class Reference

[Memory Management]

template< class T>

class mi::base::Std_allocator< T>

Description

An adaptor class template that implements a standard STL allocator. The implementation of the STL allocator is based on the mi::base::IAllocator interface.

Include File:

#include <mi/base/std_allocator.h>

Public Inner Classes

struct 
Rebind helper struct to define a new class instance of this allocator template instantiated for the new value type T1. More...

Public Typedefs

typedef T *  const_pointer
Const pointer type.
typedef T &  const_reference
Const reference type.
typedef MISTD::ptrdiff_t  difference_type
Difference type.
typedef T *  pointer
Pointer type.
typedef T &  reference
Reference type.
typedef MISTD::size_t  size_type
Size type.
typedef T  value_type
Value type allocated by this allocator.

Public Constructors

 Std_allocator()
Default constructor. More...
 Std_allocator( base::​IAllocator* allocator)
Constructor. More...
template< class T1> Std_allocator( const Std_allocator < T1 >& other)
Copying constructor template for alike allocators of different value type.

Public Member Functions

pointer address( reference x) const
Returns address of object x allocated through this allocator.
const_pointer address( const_reference x) const
Returns const address of object x allocated through this allocator.
T* allocate( size_type n, const void* = 0) throw( )
Allocate uninitialized dynamic memory for n elements of type T. More...
void construct( pointer p, const_reference value)
Calls the copy constructor of T on the location p with the argument value.
void deallocate( pointer p, size_type)
Frees uninitialized dynamic memory at location p that has previously been allocated with allocate(). More...
void destroy( pointer p)
Calls the destructor of T on the location p.
IAllocatorget_allocator() const
Returns the interface of the underlying allocator.
size_type max_size() const throw( )
Returns the maximum number of elements of type T that can be allocated using this allocator.
template< class T2>bool  operator!=( Std_allocator < T2 > other) const throw( )
Inequality comparison. More...
template< class T2>bool  operator==( Std_allocator < T2 > other) const throw( )
Equality comparison. More...

Typedefs

typedef T * mi::base::Std_allocator< T>::const_pointer

Const pointer type.

typedef T & mi::base::Std_allocator< T>::const_reference

Const reference type.

typedef MISTD::ptrdiff_t mi::base::Std_allocator< T>::difference_type

Difference type.

typedef T * mi::base::Std_allocator< T>::pointer

Pointer type.

typedef T & mi::base::Std_allocator< T>::reference

Reference type.

typedef MISTD::size_t mi::base::Std_allocator< T>::size_type

Size type.

typedef T mi::base::Std_allocator< T>::value_type

Value type allocated by this allocator.

Constructors

mi::base::Std_allocator< T>::Std_allocator() [inline]

Default constructor. Uses mi::base::Default_allocator.

mi::base::Std_allocator< T>::Std_allocator( base::​IAllocator* allocator) [inline]

Constructor. Constructor from an mi::base::IAllocator interface.

Parameters

allocator
An implementation of the mi::base::IAllocator interface. Can be NULL in which case the mi::base::Default_allocator will be used.

template< class T1>

mi::base::Std_allocator< T>::Std_allocator( const Std_allocator < T1 >& other) [inline]

Copying constructor template for alike allocators of different value type.

Member Functions

pointer mi::base::Std_allocator< T>::address( reference x) const [inline]

Returns address of object x allocated through this allocator.

const_pointer mi::base::Std_allocator< T>::address( const_reference x) const [inline]

Returns const address of object x allocated through this allocator.

T* mi::base::Std_allocator< T>::allocate( size_type n, const void* = 0) throw( ) [inline]

Allocate uninitialized dynamic memory for n elements of type T.

Returns

The pointer to the allocated memory. Can be NULL if the underlying IAllocator implementation fails to allocate the memory.

void mi::base::Std_allocator< T>::construct( pointer p, const_reference value) [inline]

Calls the copy constructor of T on the location p with the argument value.

void mi::base::Std_allocator< T>::deallocate( pointer p, size_type) [inline]

Frees uninitialized dynamic memory at location p that has previously been allocated with allocate().

Parameters

p
the memory to be freed. If p is equal to NULL, no operation is performed. However, note that according to
void mi::base::Std_allocator< T>::destroy( pointer p) [inline]

Calls the destructor of T on the location p.

IAllocator* mi::base::Std_allocator< T>::get_allocator() const [inline]

Returns the interface of the underlying allocator.

size_type mi::base::Std_allocator< T>::max_size() const throw( ) [inline]

Returns the maximum number of elements of type T that can be allocated using this allocator.

template< class T2>

bool mi::base::Std_allocator< T>::operator!=( Std_allocator < T2 > other) const throw( ) [inline]

Inequality comparison. Returns false if the underlying IAllocator interface implementations are the same.

template< class T2>

bool mi::base::Std_allocator< T>::operator==( Std_allocator < T2 > other) const throw( ) [inline]

Equality comparison. Returns true if the underlying IAllocator interface implementations are the same, because then these allocators can be used interchangeably for allocation and deallocation.