Go to the documentation of this file.
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); \
void aligned_free(void *ptr)
Aligned allocator that is compatible with C++11.
aligned_allocator_cpp11()
std::shared_ptr< T > make_aligned_shared(Args &&... args)
Creates a shared_ptr with aligned memory via aligned_allocator_cpp11<>.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void * aligned_malloc(size_t size, size_t alignment)
GLuint GLuint GLsizei GLenum type
const T & const_reference
void * aligned_realloc(void *ptr, size_t size, size_t alignment)
std::ptrdiff_t difference_type
aligned_allocator_cpp11(const aligned_allocator_cpp11< U > &other)
void * aligned_calloc(size_t bytes, size_t alignment)
Identical to aligned_malloc, but it zeroes the reserved memory block.
pointer allocate(size_type num, const void *=nullptr)
aligned_allocator_cpp11(const aligned_allocator_cpp11 &other)
~aligned_allocator_cpp11()
void deallocate(pointer p, size_type)
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |