9 template <
typename T = std::
byte>
36 return static_cast<T*
>(
resource_->allocate(
sizeof(T) * count,
alignof(T)));
42 void deallocate(T* address, std::size_t count)
noexcept {
43 resource_->deallocate(address,
sizeof(T) * count,
alignof(T));
50 template <
typename U,
typename... Args>
52 ::new (address) U(std::forward<Args>(args)...);
70 return lhs.resource_ == rhs.resource_;
A default memory resource that wraps global operator new and operator delete.
A memory resource holder interface for the PolymorphicAllocator. Responsible for allocate and dealloc...
MemoryResource * resource_
Non-owning pointer to memory resource.
void deallocate(T *address, std::size_t count) noexcept
Deallocate memory.
friend bool operator==(const PolymorphicAllocator< T > &lhs, const PolymorphicAllocator< U > &rhs) noexcept
PolymorphicAllocator(MemoryResource &resource) noexcept
Construct allocator with a specific memory resource.
PolymorphicAllocator() noexcept
Default constructor using the default memory resource.
friend class PolymorphicAllocator
T * allocate(std::size_t count)
Allocate memory for count objects.
PolymorphicAllocator(const PolymorphicAllocator< U > &allocator) noexcept
Copy constructor from another polymorphic allocator.
void destroy(U *address) noexcept
Destroy the object at the given address.
void construct(U *address, Args &&... args)
Construct an object in place at the given address.
friend bool operator!=(const PolymorphicAllocator< T > &lhs, const PolymorphicAllocator< U > &rhs) noexcept