Go to the documentation of this file.
35 #ifndef ALLOCATORS_ALIGNED_H
36 #define ALLOCATORS_ALIGNED_H
39 #include <boost/cstdint.hpp>
55 const int pointerSize =
sizeof(
void*);
56 const int requestedSize = size + alignment - 1 + pointerSize;
57 void* raw = std::malloc(requestedSize);
64 void* start = (uint8_t*)raw + pointerSize;
65 void* aligned = (
void*)(((uintptr_t)((uint8_t*)start+alignment-1)) & ~(alignment-1));
66 *(
void**)((uint8_t*)aligned-pointerSize) = raw;
81 void* raw = *(
void**)((uint8_t*)aligned -
sizeof(
void*));
88 template<
size_t align>
109 template<
class T,
size_t align>
110 class AlignedAllocator
152 throw std::bad_alloc();
155 return static_cast<pointer>(mem);
174 #endif // ALLOCATORS_ALIGNED_H
const typedef T & const_reference
pointer address(reference r) const
void * alignedMalloc(size_t size, size_t alignment)
Allocate memory aligned at on a value. Memory allocated through alignedMalloc() must be freed through...
const typedef T * const_pointer
void deallocate(pointer p, size_type n)
void alignedFree(void *aligned)
Free memory allocated through alignedMalloc()
void construct(pointer p, const_reference val)
size_type max_size() const
An stl-compatible aligned allocator.
ptrdiff_t difference_type
pointer allocate(size_type n, typename AlignedAllocator< void, align >::const_pointer hint=0)
AlignedAllocator< U, align > other
allocators
Author(s): Josh Faust
autogenerated on Wed Mar 2 2022 00:54:11