diff --git a/Include/auROXTL/auMemoryModel.hpp b/Include/auROXTL/auMemoryModel.hpp index c157590..fd99b97 100644 --- a/Include/auROXTL/auMemoryModel.hpp +++ b/Include/auROXTL/auMemoryModel.hpp @@ -190,25 +190,29 @@ static constexpr AuUInt AuArraySize(const T(&array)[Z]) } template -#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 +static auto AuTryLockMemoryType(T weak) -> decltype(weak.lock()) +{ + if (weak.expired()) + { + return {}; + } + + AUROXTL_COMMODITY_TRY + { + return weak.lock(); + } + AUROXTL_COMMODITY_CATCH + { + return {}; + } } template