interface ov::AllocatorImpl

Overview

Tries to act like std::pmr::memory_resource More…

#include <allocator.hpp>

template AllocatorImpl: public std::enable_shared_from_this< AllocatorImpl >
{
    // typedefs

    typedef std::shared_ptr<AllocatorImpl> Ptr;

    // methods

    virtual void \* allocate(
        const size_t bytes,
        const size_t alignment = alignof(max_align_t)
        ) = 0;

    virtual void deallocate(
        void \* handle,
        const size_t bytes,
        size_t alignment = alignof(max_align_t)
        ) = 0;

    virtual bool is_equal(const AllocatorImpl& other) const = 0;

protected:
};

Detailed Documentation

Tries to act like std::pmr::memory_resource

Typedefs

typedef std::shared_ptr<AllocatorImpl> Ptr

A smart pointer containing AllocatorImpl object.

Methods

virtual void \* allocate(
    const size_t bytes,
    const size_t alignment = alignof(max_align_t)
    ) = 0

Allocates memory.

Parameters:

bytes

The size in bytes at least to allocate

alignment

The alignment of storage

Exception

if specified size and alignment is not supported

Returns:

Handle to the allocated resource

virtual void deallocate(
    void \* handle,
    const size_t bytes,
    size_t alignment = alignof(max_align_t)
    ) = 0

Releases the handle and all associated memory resources which invalidates the handle.

Parameters:

handle

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

virtual bool is_equal(const AllocatorImpl& other) const = 0

Compares 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