Graphite
Version 3
An experimental 3D geometry processing program
|
An allocator that performs aligned memory allocations. More...
#include <geogram/basic/memory.h>
Classes | |
struct | rebind |
Defines the same allocator for other types. More... | |
Public Types | |
typedef T | value_type |
Element type. | |
typedef T * | pointer |
Pointer to element. | |
typedef T & | reference |
Reference to element. | |
typedef const T * | const_pointer |
Pointer to constant element. | |
typedef const T & | const_reference |
Reference to constant element. | |
typedef ::std::size_t | size_type |
Quantities of elements. | |
typedef ::std::ptrdiff_t | difference_type |
Difference between two pointers. | |
Public Member Functions | |
pointer | address (reference x) |
Gets the address of an object. More... | |
const_pointer | address (const_reference x) |
Gets the address of a object. More... | |
pointer | allocate (size_type nb_elt, const void *hint=nullptr) |
Allocates a block of storage. More... | |
void | deallocate (pointer p, size_type nb_elt) |
Releases a block of storage. More... | |
size_type | max_size () const |
Gets the maximum size possible to allocate. More... | |
void | construct (pointer p, const_reference val) |
Constructs an object. More... | |
void | destroy (pointer p) |
Destroys an object. More... | |
template<class T2 , int A2> | |
operator aligned_allocator< T2, A2 > () | |
Conversion operator to different aligned_allocator. More... | |
An allocator that performs aligned memory allocations.
The allocator can be used as a template argument for STL containers. It is required for efficient vectorization of the code using vector processing units (SSE,AVX or AVX-512).
|
inline |
|
inline |
|
inline |
Allocates a block of storage.
Attempts to allocate a block of storage with a size large enough to contain n
elements of member type value_type
(an alias of the allocator's template parameter), and returns a pointer to the first element. The storage is aligned on ALIGN bytes, but they are not constructed.
[in] | nb_elt | number of elements to allocate |
[in] | hint | Either 0 or a valer 0 or a value previously obtained by another call to allocate and not yet freed with deallocate. When it is not 0, this value may be used as a hint to improve performance by allocating the new block near the one specified. The address of an adjacent element is often a good choice. |
|
inline |
Constructs an object.
Constructs an element object on the location pointed by p
. Notice that this does not allocate space for the element. It should already be available at p (see member allocate() to allocate space).
[in] | p | pointer to a location with enough storage space to contain an element of type value_type. |
[in] | val | value to initialize the constructed element to. |
|
inline |
Releases a block of storage.
Releases a block of storage previously allocated with member allocate()) and not yet released. The elements in the array are not destroyed by a call to this member function.
[in] | p | Pointer to a block of storage previously allocated with aligned_allocator::allocate. |
[in] | nb_elt | Number of elements allocated on the call to aligned_allocator::allocate() for this block of storage. |
|
inline |
Destroys an object.
Destroys in-place the object pointed by p. Notice that this does not deallocate the storage for the element (see member deallocate() to release storage space).
[in] | p | pointer to the object to be destroyed. |
|
inline |
Gets the maximum size possible to allocate.
value_type
that could potentially be allocated by a call to member allocate().
|
inline |
Conversion operator to different aligned_allocator.
Required when compiling under MSVC version <= 2010