This commit is contained in:
Reece Wilson 2024-04-21 06:53:34 +01:00
parent b47cf9f181
commit 76b5466e87

View File

@ -152,19 +152,13 @@ namespace Aurora::Memory
template <class U, class... Args >
void construct(U *p, Args&&... args)
{
if constexpr (AuIsClass_v<U>)
{
new ((void *)p) U(AuForward<Args &&>(args)...);
}
new ((void *)p) U(AuForward<Args>(args)...);
}
template <class U, class... Args >
void construct_at(U *p, Args&&... args)
{
if constexpr (AuIsClass_v<U>)
{
new ((void *)p) U(AuForward<Args &&>(args)...);
}
new ((void *)p) U(AuForward<Args>(args)...);
}
void deallocate(const T *pType,
@ -199,18 +193,14 @@ namespace Aurora::Memory
U *new_object(CtorArgs&&... args)
{
U *p = this->allocate_object<U>();
if constexpr (AuIsClass_v<U> &&
!AuIsTriviallyConstructible_v<U, CtorArgs>)
try
{
try
{
this->construct(p, AuForward<CtorArgs>(args)...);
}
catch (...)
{
this->deallocate_object(p);
throw;
}
this->construct(p, AuForward<CtorArgs>(args)...);
}
catch (...)
{
this->deallocate_object(p);
throw;
}
return p;
}