5#include <memory_resource>
19 using base = std::pmr::polymorphic_allocator<byte_t>;
26 const std::pmr::polymorphic_allocator<U> &other) noexcept
30 : std::pmr::polymorphic_allocator<byte_t>(resource) {}
34 size_t alignment = EIGEN_DEFAULT_ALIGN_BYTES) {
35 return static_cast<T *
>(resource()->allocate(n *
sizeof(T), alignment));
40 size_t alignment = EIGEN_DEFAULT_ALIGN_BYTES) {
41 resource()->deallocate(p, n *
sizeof(T), alignment);
46 size_t alignment = EIGEN_DEFAULT_ALIGN_BYTES) {
47 return resource()->allocate(num_bytes, alignment);
51 size_t alignment = EIGEN_DEFAULT_ALIGN_BYTES) {
52 resource()->deallocate(p, num_bytes, alignment);
59struct std::allocator_traits<
aligator::polymorphic_allocator>
60 : std::allocator_traits<aligator::polymorphic_allocator::base> {
61 using allocator_type = aligator::polymorphic_allocator;
polymorphic_allocator(std::pmr::memory_resource *resource) noexcept
void * allocate_bytes(size_t num_bytes, size_t alignment=EIGEN_DEFAULT_ALIGN_BYTES)
T * allocate(size_t n, size_t alignment=EIGEN_DEFAULT_ALIGN_BYTES)
std::pmr::polymorphic_allocator< byte_t > base
polymorphic_allocator(const polymorphic_allocator &other)=default
polymorphic_allocator() noexcept
void deallocate_bytes(void *p, size_t num_bytes, size_t alignment=EIGEN_DEFAULT_ALIGN_BYTES)
void deallocate(T *p, size_t n, size_t alignment=EIGEN_DEFAULT_ALIGN_BYTES)
polymorphic_allocator(const std::pmr::polymorphic_allocator< U > &other) noexcept