From bdb5e3e37a2cf3dba3e95990c1a71a129fb3b09e Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Tue, 10 Sep 2024 08:28:47 +0100 Subject: [PATCH] [*] Split off some auMemoryModel.hpp resources --- Include/auROXTL/MemoryModel/auArraySize.hpp | 14 ++++++++ Include/auROXTL/MemoryModel/auOffsetOf.hpp | 16 +++++++++ Include/auROXTL/MemoryModel/auSizeOf.hpp | 38 ++++++++++++++++++++ Include/auROXTL/auMemoryModel.hpp | 39 ++------------------- 4 files changed, 71 insertions(+), 36 deletions(-) create mode 100644 Include/auROXTL/MemoryModel/auArraySize.hpp create mode 100644 Include/auROXTL/MemoryModel/auOffsetOf.hpp create mode 100644 Include/auROXTL/MemoryModel/auSizeOf.hpp diff --git a/Include/auROXTL/MemoryModel/auArraySize.hpp b/Include/auROXTL/MemoryModel/auArraySize.hpp new file mode 100644 index 0000000..f103262 --- /dev/null +++ b/Include/auROXTL/MemoryModel/auArraySize.hpp @@ -0,0 +1,14 @@ +/*** + Copyright (C) 2023-2024 Jamie Reece Wilson (a/k/a "Reece"). All rights reserved. + + File: auArraySize.hpp + Date: 2022-02-01 - 2024-09-09 + Author: Reece +***/ +#pragma once + +template +constexpr AuUInt AuArraySize(const T(&array)[Z]) +{ + return Z; +} \ No newline at end of file diff --git a/Include/auROXTL/MemoryModel/auOffsetOf.hpp b/Include/auROXTL/MemoryModel/auOffsetOf.hpp new file mode 100644 index 0000000..682f8f9 --- /dev/null +++ b/Include/auROXTL/MemoryModel/auOffsetOf.hpp @@ -0,0 +1,16 @@ +/*** + Copyright (C) 2023-2024 Jamie Reece Wilson (a/k/a "Reece"). All rights reserved. + + File: auOffsetOf.hpp + Date: 2023-02-04 - 2024-09-09 + Author: Reece +***/ +#pragma once + +template +AuUInt AuOffsetOf(C T:: *offset) +{ + return AuUInt( + &(((const T *)(nullptr))->*offset) + ); +} \ No newline at end of file diff --git a/Include/auROXTL/MemoryModel/auSizeOf.hpp b/Include/auROXTL/MemoryModel/auSizeOf.hpp new file mode 100644 index 0000000..9dbeabe --- /dev/null +++ b/Include/auROXTL/MemoryModel/auSizeOf.hpp @@ -0,0 +1,38 @@ +/*** + Copyright (C) 2023-2024 Jamie Reece Wilson (a/k/a "Reece"). All rights reserved. + + File: auSizeOf.hpp + Date: 2023-02-04 - 2024-09-09 + Author: Reece +***/ +#pragma once + +template +constexpr AuUInt AuSizeOf() +{ + return sizeof(T); +} + +template +constexpr AuUInt AuSizeOf(const T &) +{ + return sizeof(T); +} + +template +constexpr AuUInt AuSizeOf(const T *) +{ + return sizeof(T); +} + +template +constexpr AuUInt AuSizeOf(const AuSPtr) +{ + return sizeof(T); +} + +template +constexpr AuUInt AuSizeOf(const AuUPtr &) +{ + return sizeof(T); +} \ No newline at end of file diff --git a/Include/auROXTL/auMemoryModel.hpp b/Include/auROXTL/auMemoryModel.hpp index ecc53cf..456e17c 100644 --- a/Include/auROXTL/auMemoryModel.hpp +++ b/Include/auROXTL/auMemoryModel.hpp @@ -59,19 +59,10 @@ static auline void AuMemoryPanic(const char *msg) #endif } -template -static constexpr AuUInt AuArraySize(const T(&array)[Z]) -{ - return Z; -} +#include "MemoryModel/auArraySize.hpp" +#include "MemoryModel/auSizeOf.hpp" +#include "MemoryModel/auOffsetOf.hpp" -template -static AuUInt AuOffsetOf(C T:: *offset) -{ - return AuUInt( - &(((const T *)(nullptr))->*offset) - ); -} template static auto AuTryLockMemoryType(T weak) -> decltype(weak.lock()) @@ -91,30 +82,6 @@ static auto AuTryLockMemoryType(T weak) -> decltype(weak.lock()) } } -template -constexpr AuUInt AuSizeOf() -{ - return sizeof(T); -} - -template -constexpr AuUInt AuSizeOf(const T &) -{ - return sizeof(T); -} - -template -constexpr AuUInt AuSizeOf(const T *) -{ - return sizeof(T); -} - -template -constexpr AuUInt AuSizeOf(const AuSPtr) -{ - return sizeof(T); -} - template static void auline AuSafeDelete(T *in) {