14 #ifndef QMCPLUSPLUS_ALIGNED_ALLOCATOR_H 15 #define QMCPLUSPLUS_ALIGNED_ALLOCATOR_H 24 template<
typename T,
size_t ALIGN>
48 throw std::runtime_error(
"Mallocator::allocate does not accept size 0 allocations.");
50 std::size_t asize =
n *
sizeof(T);
51 std::size_t amod = asize % ALIGN;
53 asize += ALIGN - amod;
55 #if __STDC_VERSION__ >= 201112L || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16) 61 pt = aligned_alloc(ALIGN, asize);
66 posix_memalign(&pt, ALIGN, asize);
69 throw std::runtime_error(
"Allocation failed in Mallocator, requested size in bytes = " +
70 std::to_string(
n *
sizeof(T)));
71 return static_cast<T*
>(pt);
77 throw std::runtime_error(
"Mallocator::deallocate does not accept size 0 allocations.");
82 template<
class T1,
size_t ALIGN1,
class T2,
size_t ALIGN2>
85 return ALIGN1 == ALIGN2;
87 template<
class T1,
size_t ALIGN1,
class T2,
size_t ALIGN2>
90 return ALIGN1 != ALIGN2;
helper functions for EinsplineSetBuilder
static constexpr size_t alignment
bool operator==(const Matrix< T, Alloc > &lhs, const Matrix< T, Alloc > &rhs)
void deallocate(T *p, std::size_t n)
const RealType * * const_pointer
T * allocate(std::size_t n)
bool operator!=(const Matrix< T, Alloc > &lhs, const Matrix< T, Alloc > &rhs)
Mallocator(const Mallocator< U, ALIGN > &)