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));
|
|
|
|
new (&ref) T(AuForward<Args &&>(args)...);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ref = AuDecay_t<T>();
|
|
|
|
}
|
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);
|