2022-08-26 12:47:17 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: ResetMember.hpp
|
|
|
|
Date: 2022-08-26
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
2022-11-17 02:28:23 +00:00
|
|
|
template <class T, class ...Args>
|
|
|
|
static void AuResetMember(T &ref, Args &&...args)
|
2022-08-26 12:47:17 +00:00
|
|
|
{
|
2022-11-17 02:28:23 +00:00
|
|
|
if constexpr (AuIsClass_v<T>)
|
|
|
|
{
|
|
|
|
ref.~T();
|
|
|
|
AuMemset(&ref, 0, sizeof(ref));
|
2024-06-26 08:22:12 +00:00
|
|
|
new (&ref) T(AuForward<Args>(args)...);
|
|
|
|
}
|
|
|
|
else if constexpr (AuIsArray_v<T>)
|
|
|
|
{
|
|
|
|
for (AU_ITERATE_N(i, AuArraySize(ref)))
|
|
|
|
{
|
|
|
|
AuResetMember(ref[i]);
|
|
|
|
}
|
2022-11-17 02:28:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-06-26 08:22:12 +00:00
|
|
|
ref = T {};
|
2022-11-17 02:28:23 +00:00
|
|
|
}
|
2022-08-26 12:47:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
static void AuResetMember(AuSPtr<T> &ref)
|
|
|
|
{
|
|
|
|
ref.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Aurora::Memory
|
|
|
|
{
|
|
|
|
struct ByteBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
static void AuResetMember(Aurora::Memory::ByteBuffer &ref);
|