5 #ifndef DUNE_ALIGNED_ALLOCATOR_HH 6 #define DUNE_ALIGNED_ALLOCATOR_HH 10 #include <type_traits> 22 template<
class T,
int Alignment = -1>
37 static constexpr
int fixAlignment(
int align)
39 return ((Alignment==-1) ? std::alignment_of<T>::value : Alignment) > align
40 ? fixAlignment(align << 1) : align;
49 static constexpr
int fixAlignment(
int align)
51 return (Alignment==-1) ? std::alignment_of<T>::value : Alignment;
63 static constexpr
int alignment = fixAlignment(
sizeof(
void*));
69 throw std::bad_alloc();
88 throw std::bad_alloc();
103 #endif // DUNE_ALIGNED_ALLOCATOR_HH AlignedAllocator< U, Alignment > other
Definition: alignedallocator.hh:60
T * pointer
Definition: mallocallocator.hh:28
typename MallocAllocator< T >::size_type size_type
Definition: alignedallocator.hh:58
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
Definition: alignedallocator.hh:59
size_type max_size() const noexcept
max size for allocate
Definition: mallocallocator.hh:74
Dune namespace
Definition: alignedallocator.hh:12
void deallocate(pointer p, [[maybe_unused]] size_type n)
deallocate n objects of type T at address p
Definition: mallocallocator.hh:68
std::size_t size_type
Definition: mallocallocator.hh:26
pointer allocate(size_type n, [[maybe_unused]] const void *hint=0)
allocate n objects of type T
Definition: alignedallocator.hh:66
typename MallocAllocator< T >::pointer pointer
Definition: alignedallocator.hh:57
Allocators which guarantee alignment of the memory.
Definition: alignedallocator.hh:23
static constexpr int alignment
Definition: alignedallocator.hh:63
Allocators implementation which simply calls malloc/free.
Definition: mallocallocator.hh:24
Allocators that use malloc/free.