3#ifndef DUNE_ALIGNED_ALLOCATOR_HH
4#define DUNE_ALIGNED_ALLOCATOR_HH
20 template<
class T,
int Alignment = -1>
27 static constexpr int fixAlignment(
int align)
29 return (Alignment==-1) ? std::alignment_of<T>::value : Alignment;
33 using pointer =
typename MallocAllocator<T>::pointer;
34 using size_type =
typename MallocAllocator<T>::size_type;
35 template <
class U>
struct rebind {
39 static constexpr int alignment = fixAlignment(
sizeof(
void*));
42 pointer
allocate(size_type n, [[maybe_unused]]
const void* hint = 0)
45 throw std::bad_alloc();
50 pointer ret =
static_cast<pointer
>(std::aligned_alloc(alignment, n *
sizeof(T)));
52 throw std::bad_alloc();
Allocators which guarantee alignment of the memory.
Definition: alignedallocator.hh:21
pointer allocate(size_type n, const void *hint=0)
allocate n objects of type T
Definition: alignedallocator.hh:42
Allocators implementation which simply calls malloc/free.
Definition: mallocallocator.hh:22
size_type max_size() const noexcept
max size for allocate
Definition: mallocallocator.hh:72
Allocators that use malloc/free.
Dune namespace.
Definition: alignedallocator.hh:11