[*] Split off some auMemoryModel.hpp resources

This commit is contained in:
Reece Wilson 2024-09-10 08:28:47 +01:00
parent 37bb7e805e
commit bdb5e3e37a
4 changed files with 71 additions and 36 deletions

View File

@ -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 <class T, AuUInt Z>
constexpr AuUInt AuArraySize(const T(&array)[Z])
{
return Z;
}

View File

@ -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 <typename T, typename C>
AuUInt AuOffsetOf(C T:: *offset)
{
return AuUInt(
&(((const T *)(nullptr))->*offset)
);
}

View File

@ -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 <typename T>
constexpr AuUInt AuSizeOf()
{
return sizeof(T);
}
template <typename T>
constexpr AuUInt AuSizeOf(const T &)
{
return sizeof(T);
}
template <typename T>
constexpr AuUInt AuSizeOf(const T *)
{
return sizeof(T);
}
template <typename T>
constexpr AuUInt AuSizeOf(const AuSPtr<T>)
{
return sizeof(T);
}
template <typename T, class Del_t>
constexpr AuUInt AuSizeOf(const AuUPtr<T, Del_t> &)
{
return sizeof(T);
}

View File

@ -59,19 +59,10 @@ static auline void AuMemoryPanic(const char *msg)
#endif
}
template <class T, AuUInt Z>
static constexpr AuUInt AuArraySize(const T(&array)[Z])
{
return Z;
}
#include "MemoryModel/auArraySize.hpp"
#include "MemoryModel/auSizeOf.hpp"
#include "MemoryModel/auOffsetOf.hpp"
template <typename T, typename C>
static AuUInt AuOffsetOf(C T:: *offset)
{
return AuUInt(
&(((const T *)(nullptr))->*offset)
);
}
template <typename T>
static auto AuTryLockMemoryType(T weak) -> decltype(weak.lock())
@ -91,30 +82,6 @@ static auto AuTryLockMemoryType(T weak) -> decltype(weak.lock())
}
}
template <typename T>
constexpr AuUInt AuSizeOf()
{
return sizeof(T);
}
template <typename T>
constexpr AuUInt AuSizeOf(const T &)
{
return sizeof(T);
}
template <typename T>
constexpr AuUInt AuSizeOf(const T *)
{
return sizeof(T);
}
template <typename T>
constexpr AuUInt AuSizeOf(const AuSPtr<T>)
{
return sizeof(T);
}
template <class Z, typename T>
static void auline AuSafeDelete(T *in)
{