AuROXTL/Include/auROXTL/Objects/ResetMember.hpp
Reece Wilson dba4a884ca [+] AuTryCall
[+] AuTryCallPair
[+] AuIsCallable
[+] AuIsCallable_v
[*] Improved AuResetMember
2022-11-17 02:28:23 +00:00

37 lines
675 B
C++

/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: ResetMember.hpp
Date: 2022-08-26
Author: Reece
***/
#pragma once
template <class T, class ...Args>
static void AuResetMember(T &ref, Args &&...args)
{
if constexpr (AuIsClass_v<T>)
{
ref.~T();
AuMemset(&ref, 0, sizeof(ref));
new (&ref) T(AuForward<Args &&>(args)...);
}
else
{
ref = AuDecay_t<T>();
}
}
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);