12 #include <type_traits> 16 #if defined(__AVX2__) || defined(EIGEN_VECTORIZE_AVX512) 17 #define MRPT_MAX_ALIGN_BYTES 64 18 #elif defined(__AVX__) 19 #define MRPT_MAX_ALIGN_BYTES 32 21 #define MRPT_MAX_ALIGN_BYTES 16 37 template <
class T,
size_t AligmentBytes = MRPT_MAX_ALIGN_BYTES>
57 :
std::allocator<T>(other)
62 :
std::allocator<T>(other)
77 template <
typename T,
class... Args>
81 return std::allocate_shared<T>(
90 #define MRPT_MAKE_ALIGNED_OPERATOR_NEW \ 91 void* operator new(size_t size) \ 93 return mrpt::aligned_malloc(size, MRPT_MAX_ALIGN_BYTES); \ 95 void* operator new[](size_t size) \ 97 return mrpt::aligned_malloc(size, MRPT_MAX_ALIGN_BYTES); \ 99 void operator delete(void* ptr) noexcept { mrpt::aligned_free(ptr); } \ 100 void operator delete[](void* ptr) noexcept { mrpt::aligned_free(ptr); } \ 104 static void* operator new(size_t size, void* ptr) \ 106 return ::operator new(size, ptr); \ 108 void operator delete(void* memory, void* ptr) noexcept \ 110 return ::operator delete(memory, ptr); \ 113 void* operator new(size_t size, const std::nothrow_t&) noexcept \ 117 return mrpt::aligned_malloc(size, MRPT_MAX_ALIGN_BYTES); \ 124 void operator delete(void* ptr, const std::nothrow_t&)noexcept \ 126 mrpt::aligned_free(ptr); \ std::ptrdiff_t difference_type
void aligned_free(void *ptr)
pointer allocate(size_type num, const void *=nullptr)
aligned_allocator_cpp11(const aligned_allocator_cpp11< U > &other)
const T & const_reference
void * aligned_malloc(size_t size, size_t alignment)
~aligned_allocator_cpp11()
Aligned allocator that is compatible with C++11.
void * aligned_realloc(void *ptr, size_t size, size_t alignment)
void * aligned_calloc(size_t bytes, size_t alignment)
Identical to aligned_malloc, but it zeroes the reserved memory block.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::shared_ptr< T > make_aligned_shared(Args &&... args)
Creates a shared_ptr with aligned memory via aligned_allocator_cpp11<>.
aligned_allocator_cpp11(const aligned_allocator_cpp11 &other)
void deallocate(pointer p, size_type)
aligned_allocator_cpp11()
GLuint GLuint GLsizei GLenum type