General Purpose library for Freestanding C++ and POSIX systems
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 

43 行
962 B

#pragma once
#include <stddef.h>
namespace gp {
/**
* @brief The base for all polymorphic allocators
*/
struct allocator{
/**
* @brief Allocates memory
*
* @param sz the amount of bytes to allocate
*
* @return the allocated memory as a pointer on success
* @return nullptr if it failed allocating
*/
virtual void* allocate(size_t) = 0;
/**
* @brief Deallocates memory
*
* @param ptr the memory to deallocate
*
* @return true if the memory was successfully deallocated
* @return false if the memory was not deallocated
*/
virtual bool deallocate(void*) = 0;
/**
* @brief Tries to reallocate memory
*
* @param ptr The memory to reallocate
* @param sz The new size we want to give the memory
*
* @return true if reallocation was successful
* @return false if the reallocation failed
*/
virtual bool try_reallocate(void*, size_t) = 0;
virtual ~allocator() = default;
};
}