class ov::Allocator¶
Overview¶
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. More…
#include <allocator.hpp>
class Allocator
{
public:
// construction
Allocator();
Allocator(const Allocator& other);
Allocator(Allocator&& other);
Allocator(const AllocatorImpl::Ptr& impl);
// methods
Allocator& operator = (const Allocator& other);
Allocator& operator = (Allocator&& other);
void \* allocate(
const size_t bytes,
const size_t alignment = alignof(max_align_t)
);
void deallocate(
void \* ptr,
const size_t bytes = 0,
const size_t alignment = alignof(max_align_t)
);
bool operator == (const Allocator& other) const;
bool operator ! () const;
operator bool () const;
};Detailed Documentation¶
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.
Construction¶
Allocator()Default constructor.
Allocator(const Allocator& other)Default copy constructor.
Parameters:
other |
other Allocator object |
Allocator(Allocator&& other)Default move constructor.
Parameters:
other |
other Allocator object |
Allocator(const AllocatorImpl::Ptr& impl)Constructs Allocator from the initialized std::shared_ptr.
Parameters:
impl |
Initialized shared pointer |
Methods¶
Allocator& operator = (const Allocator& other)Default copy assignment operator.
Parameters:
other |
other Allocator object |
Returns:
reference to the current object
Allocator& operator = (Allocator&& other)Default move assignment operator.
Parameters:
other |
other Allocator object |
Returns:
reference to the current 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 |
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) constCompares with other AllocatorImpl.
Parameters:
other |
Other instance of allocator |
Returns:
true if and only if memory allocated from one AllocatorImpl can be deallocated from the other and vice versa
bool operator ! () constChecks if current Allocator object is not initialized.
Returns:
true if current Allocator object is not initialized, false - otherwise
operator bool () constChecks if current Allocator object is initialized.
Returns:
true if current Allocator object is initialized, false - otherwise