General Purpose library for Freestanding C++ and POSIX systems
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 

59 líneas
1.3 KiB

#pragma once
#include "gp_config.hpp"
#include "gp/exception.hpp"
#include <type_traits>
// XXX: THIS FILE SHOULD BE REMOVED, AS SHOULD ALL DEPENDENCIES ON THE C-ALLOCATOR AS IS
/*
namespace gp{
template<class T, typename I = std::enable_if_t<gp_config::memory_module::is_ok,int>>
class default_memory_allocator
{
public:
using pointer_type = T*;
using reference_type = T&;
using const_pointer_type = const T*;
using const_reference_type = const T&;
pointer_type allocate(size_t sz)
{
return reinterpret_cast <pointer_type> (gp_config::memory_module::memory_allocator<gp_config::memory_module::memory_mode>(sizeof(T) * sz));
}
void deallocate(pointer_type ptr)
{
gp_config::memory_module::memory_deallocator<gp_config::memory_module::memory_mode>(ptr);
}
template<typename ...params>
pointer_type construct(pointer_type ptr, params... args)
{
new(ptr) T(args...);
return ptr;
}
void destroy(pointer_type v)
{
v->~T();
}
};
}
void* operator new(size_t sz)
{
auto ptr = gp_config::memory_module::memory_allocator<gp_config::memory_module::memory_mode>(sz);
if constexpr (gp_config::has_exceptions)
{
if(!ptr)
{
throw gp::bad_alloc{};
}
}
return ptr;
}
void operator delete (void* ptr) noexcept
{
gp_config::memory_module::memory_deallocator<gp_config::memory_module::memory_mode>(ptr);
}
*/