Class ov::Allocator#
-
class Allocator#
Wraps allocator implementation to provide safe way to store allocater loaded from shared library And constructs default based on
new
delete
c++ calls allocator if created without parameters Accepts any std::pmr::memory_resource like allocator.Public Functions
-
~Allocator()#
Destructor preserves unloading order of implementation object and reference to library.
-
Allocator()#
Default constructor.
-
Allocator(const Allocator &other) = default#
Default copy constructor.
- Parameters:
other – other Allocator object
-
Allocator &operator=(const Allocator &other) = default#
Default copy assignment operator.
- Parameters:
other – other Allocator object
- Returns:
reference to the current object
-
Allocator(Allocator &&other) = default#
Default move constructor.
- Parameters:
other – other Allocator object
-
Allocator &operator=(Allocator &&other) = default#
Default move assignment operator.
- Parameters:
other – other Allocator object
- Returns:
reference to the current object
Initialize allocator using any allocator like object.
- Template Parameters:
A – Type of allocator
- Parameters:
a – allocator object
-
void *allocate(const size_t bytes, const size_t alignment = alignof(max_align_t))#
Allocates memory.
- Parameters:
bytes – The size in bytes at least to allocate
alignment – The alignment of storage
- Throws:
Exception – if specified size and alignment is not supported
- Returns:
Handle to the allocated resource
-
void deallocate(void *ptr, const size_t bytes = 0, const size_t alignment = alignof(max_align_t))#
Releases the handle and all associated memory resources which invalidates the handle.
- Parameters:
ptr – The handle to free
bytes – The size in bytes that was passed into allocate() method
alignment – The alignment of storage that was passed into allocate() method
-
bool operator==(const Allocator &other) const#
Compares with other Allocator.
- Parameters:
other – Other instance of allocator
- Returns:
true
if and only if memory allocated from one Allocator can be deallocated from the other and vice versa
-
~Allocator()#