5#include <memory_resource>
19 using base = std::pmr::polymorphic_allocator<byte_t>;
21 :
base{std::pmr::get_default_resource()} {}
27 const std::pmr::polymorphic_allocator<U> &other) noexcept
31 : std::pmr::polymorphic_allocator<byte_t>(resource) {}
35 size_t alignment = EIGEN_DEFAULT_ALIGN_BYTES) {
36 return static_cast<T *
>(resource()->allocate(n *
sizeof(T), alignment));
41 size_t alignment = EIGEN_DEFAULT_ALIGN_BYTES) {
42 resource()->deallocate(p, n *
sizeof(T), alignment);
47 size_t alignment = EIGEN_DEFAULT_ALIGN_BYTES) {
48 return resource()->allocate(num_bytes, alignment);
52 size_t alignment = EIGEN_DEFAULT_ALIGN_BYTES) {
53 resource()->deallocate(p, num_bytes, alignment);
60struct std::allocator_traits<
aligator::polymorphic_allocator>
61 : std::allocator_traits<aligator::polymorphic_allocator::base> {
62 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