[+] MSVC AuUnsafeRaiiToShared exception throw mitigation

This commit is contained in:
Reece Wilson 2022-03-26 13:43:49 +00:00
parent a7a982194e
commit 04a1853ed0

View File

@ -68,6 +68,27 @@ static auline AuSPtr<T> AuMakeShared(Args&&... args)
} }
} }
namespace __audetail
{
struct Dummy
{
char a;
};
inline AuSPtr<Dummy> GetDummyDeleter()
{
static AuSPtr<Dummy> d;
if (!d)
{
#if defined(AURORA_COMPILER_MSVC)
return d;
#endif
d = AuMakeShared<Dummy>();
}
return d;
}
}
template <class T> template <class T>
static auline AuSPtr<T> AuMakeSharedArray(AuUInt count) static auline AuSPtr<T> AuMakeSharedArray(AuUInt count)
{ {
@ -88,15 +109,13 @@ static auline AuSPtr<T> AuMakeSharedArray(AuUInt count)
template <class T> template <class T>
static AuSPtr<T> AuUnsafeRaiiToShared(T *in) static AuSPtr<T> AuUnsafeRaiiToShared(T *in)
{ {
return AuSPtr<T>(in, [](T *) return AuSPtr<T>(__audetail::GetDummyDeleter(), in);
{});
} }
template <class T, class Z> template <class T, class Z>
static AuSPtr<T> AuUnsafeRaiiToShared(const AuUPtr<T, Z> &in) static AuSPtr<T> AuUnsafeRaiiToShared(const AuUPtr<T, Z> &in)
{ {
return AuSPtr<T>(in.get(), [](T *) return AuUnsafeRaiiToShared(in.get());
{});
} }
template <class T, AuUInt Z> template <class T, AuUInt Z>