Home | Libraries | People | FAQ | More |
boost::mpi::allocator — Standard Library-compliant allocator for the MPI-2 memory allocation routines.
// In header: <boost/mpi/allocator.hpp> template<typename T> class allocator { public: // types typedef std::size_t size_type; // Holds the size of objects. typedef std::ptrdiff_t difference_type; // Holds the number of elements between two pointers. typedef T * pointer; // A pointer to an object of typeT
. typedef const T * const_pointer; // A pointer to a constant object of typeT
. typedef T & reference; // A reference to an object of typeT
. typedef const T & const_reference; // A reference to a constant object of typeT
. typedef T value_type; // The type of memory allocated by this allocator. // member classes/structs/unions // Retrieve the type of an allocator similar to this allocator but for a // different value type. template<typename U> struct rebind { // types typedef allocator< U > other; }; // construct/copy/destruct allocator(); allocator(const allocator &); template<typename U> allocator(const allocator< U > &); ~allocator(); // public member functions pointer address(reference) const; const_pointer address(const_reference) const; pointer allocate(size_type, allocator< void >::const_pointer = 0); void deallocate(pointer, size_type); size_type max_size() const; void construct(pointer, const T &); void destroy(pointer); };
This allocator provides a standard C++ interface to the MPI_Alloc_mem
and MPI_Free_mem
routines of MPI-2. It is intended to be used with the containers in the Standard Library (vector
, in particular) in cases where the contents of the container will be directly transmitted via MPI. This allocator is also used internally by the library for character buffers that will be used in the transmission of data.
The allocator
class template only provides MPI memory allocation when the underlying MPI implementation is either MPI-2 compliant or is known to provide MPI_Alloc_mem
and MPI_Free_mem
as extensions. When the MPI memory allocation routines are not available, allocator
is brought in directly from namespace std
, so that standard allocators are used throughout. The macro BOOST_MPI_HAS_MEMORY_ALLOCATION
will be defined when the MPI-2 memory allocation facilities are available.
allocator
public member functionspointer address(reference x) const;
Returns the address of object x
.
const_pointer address(const_reference x) const;
Returns the address of object x
.
pointer allocate(size_type n, allocator< void >::const_pointer = 0);
Allocate enough memory for n
elements of type T
.
Parameters: |
|
||
Returns: |
a pointer to the newly-allocated memory |
void deallocate(pointer p, size_type);
Deallocate memory referred to by the pointer p
.
Parameters: |
|
size_type max_size() const;
Returns the maximum number of elements that can be allocated with allocate()
.
void construct(pointer p, const T & val);
Construct a copy of val
at the location referenced by p
.
void destroy(pointer p);
Destroy the object referenced by p
.