|
dune-common 2.12-git
|
Allocators which guarantee a minimum alignment of the memory. More...
#include <dune/common/alignedallocator.hh>
Classes | |
| struct | rebind |
| Rebind allocator to type U. More... | |
Public Types | |
| using | value_type = T |
| Type of the object to allocate. | |
Public Member Functions | |
| AlignedAllocator () noexcept=default | |
| Default constructor. | |
| template<class U > | |
| AlignedAllocator (const AlignedAllocator< U, MinAlignment > &) noexcept | |
| Construct an aligned allocator from another aligned allocator of different type. | |
| T * | allocate (std::size_t n) |
| Allocate n objects of type T. | |
| void | deallocate (T *p, std::size_t n) |
| Deallocate memory previously allocated with allocate() | |
Static Public Attributes | |
| static constexpr std::size_t | alignment = std::max(MinAlignment, std::alignment_of<T>::value) |
| Alignment of the allocated memory. | |
Detailed Description
class Dune::AlignedAllocator< T, MinAlignment >
Allocators which guarantee a minimum alignment of the memory.
This allocator provides a simple interface to allocate memory with a minimum alignment. The actual alignment of the allocated memory is the maximum of the minimum alignment and the alignment of the type T. This ensures that the allocated memory is always aligned to the requirements of the type T, while also allowing for bigger alignments when needed. Note that the minimum alignment is also guaranteed in rebinding, i.e. when allocating memory for a different type U.
- Template Parameters
-
T Type of the object one wants to allocate MinAlignment Minimum alignment of the allocated memory.
Member Typedef Documentation
◆ value_type
| using Dune::AlignedAllocator< T, MinAlignment >::value_type = T |
Type of the object to allocate.
Constructor & Destructor Documentation
◆ AlignedAllocator() [1/2]
|
defaultnoexcept |
Default constructor.
◆ AlignedAllocator() [2/2]
|
inlinenoexcept |
Construct an aligned allocator from another aligned allocator of different type.
Member Function Documentation
◆ allocate()
|
inline |
Allocate n objects of type T.
- Parameters
-
n Number of objects to allocate
- Returns
- Pointer to the allocated memory
◆ deallocate()
|
inline |
Deallocate memory previously allocated with allocate()
- Parameters
-
p Pointer to the memory to deallocate n Number of objects to deallocate
Member Data Documentation
◆ alignment
|
staticconstexpr |
Alignment of the allocated memory.
The documentation for this class was generated from the following file:
Legal Statements / Impressum | Hosted by TU Dresden & Uni Heidelberg | Generated by
1.9.8