[+] AuTryLockMemoryType
This commit is contained in:
parent
822508526b
commit
d29db2200c
@ -190,25 +190,29 @@ static constexpr AuUInt AuArraySize(const T(&array)[Z])
|
||||
}
|
||||
|
||||
template <typename T, typename C>
|
||||
#if defined(__INTELLISENSE__)
|
||||
// Visual Studio is smart enough to parse the constexpr expression properly
|
||||
// CL.exe however, will not. It's useful enough for figuring out magic numbers
|
||||
// in the VS, but not much else.
|
||||
constexpr
|
||||
#else
|
||||
static
|
||||
#endif
|
||||
AuUInt AuOffsetOf(C T:: *offset)
|
||||
static AuUInt AuOffsetOf(C T:: *offset)
|
||||
{
|
||||
#if defined(__INTELLISENSE__)
|
||||
constexpr T *nil = nullptr;
|
||||
constexpr C *nil2 = &(nil->*offset);
|
||||
return AuUInt(nil2);
|
||||
#else
|
||||
return AuUInt(
|
||||
&(((const T *)(nullptr))->*offset)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static auto AuTryLockMemoryType(T weak) -> decltype(weak.lock())
|
||||
{
|
||||
if (weak.expired())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
AUROXTL_COMMODITY_TRY
|
||||
{
|
||||
return weak.lock();
|
||||
}
|
||||
AUROXTL_COMMODITY_CATCH
|
||||
{
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
Loading…
Reference in New Issue
Block a user