|
SuperDex Physics C++ API
|
Virtual interface class for memory allocation and deallocation. More...
#include <allocator.h>
Public Member Functions | |
| void * | allocate (std::size_t sizeInBytes, std::size_t alignment=alignof(std::max_align_t)) |
| Allocate memory of the specified size and alignment. | |
| void | deallocate (void *ptr, std::size_t sizeInBytes, std::size_t alignment=alignof(std::max_align_t)) |
| Deallocate a block of memory that was previously allocated by this Allocator instance or by a compatible Allocator instance. | |
| bool | is_equal (Allocator const &other) const noexcept |
| Return true if memory allocated by this Allocator instance can be deallocated by the other Allocator instance, and visa versa. | |
| virtual | ~Allocator ()=default |
Protected Member Functions | |
| virtual void * | do_allocate (std::size_t sizeInBytes, std::size_t alignment)=0 |
| virtual void | do_deallocate (void *ptr, std::size_t sizeInBytes, std::size_t alignment)=0 |
| virtual bool | do_is_equal (Allocator const &other) const noexcept=0 |
Virtual interface class for memory allocation and deallocation.
This class provides a polymorphic interface for memory allocation operations, similar to std::pmr::memory_resource, which is not used because of compatibility issues with various platform/compiler combinations. Derived classes must implement the protected members.
Definition at line 47 of file allocator.h.
|
virtualdefault |
|
inline |
Allocate memory of the specified size and alignment.
| sizeInBytes | |
| alignment | Must be a power of 2. |
| std::bad_alloc |
Definition at line 95 of file allocator_inl.h.
|
inline |
Deallocate a block of memory that was previously allocated by this Allocator instance or by a compatible Allocator instance.
| ptr | Address of the memory block to deallocate. |
| sizeInBytes | Must match the size that was passed to the allocate method. |
| alignment | Must match the alignment that was passed to the allocate method. |
Definition at line 107 of file allocator_inl.h.
|
protectedpure virtual |
|
protectedpure virtual |
|
protectedpure virtualnoexcept |
|
inlinenoexcept |
Return true if memory allocated by this Allocator instance can be deallocated by the other Allocator instance, and visa versa.
| other |
Definition at line 115 of file allocator_inl.h.