[*] Improve MemoryView

This commit is contained in:
Reece Wilson 2021-09-29 09:02:01 +01:00
parent 8a6abcfdb7
commit 097f805209

View File

@ -13,6 +13,9 @@ namespace Aurora::Memory
struct MemoryView
{
using Void_t = std::conditional_t<Readonly_b, const void *, void *>;
template<typename T, int Z>
using StdArray_t = std::conditional_t<Readonly_b, const std::array<T, Z>, std::array<T, Z>>;
/*
YadaYada(MemoryView(tempstring/array/etc)) should be legal, right?
@ -44,14 +47,14 @@ namespace Aurora::Memory
this->ptr = str.data();
this->length = str.size();
}
template<typename T, int Z>
constexpr MemoryView(T(&a)[Z])
{
this->ptr = &a[0];
this->length = Z * sizeof(T);
}
template<typename T>
constexpr MemoryView(T *start, T *end)
{
@ -116,7 +119,8 @@ namespace Aurora::Memory
template<bool Readonly_b>
struct MemoryViewStream : MemoryView<Readonly_b>
{
template<typename T, typename std::enable_if<AuIsBaseOfTemplate<AURORA_RUNTIME_AU_LIST, T>::value>::type* = nullptr>
// template<typename T, typename std::enable_if<AuIsBaseOfTemplate<AURORA_RUNTIME_AU_LIST, T>::value>::type* = nullptr>
template<typename T, AU_TEMPLATE_ENABLE_WHEN(AuIsBaseOfTemplate<AURORA_RUNTIME_AU_LIST, T>::value)>
constexpr MemoryViewStream(T &list, AuUInt &length) : MemoryView<Readonly_b>(list), outVariable(length)
{
outVariable = 0;
@ -155,7 +159,7 @@ namespace Aurora::Memory
{
outVariable = 0;
}
template<typename T, int Z>
constexpr MemoryViewStream(T(&a)[Z]) : MemoryView<Readonly_b>(a), outVariable(unused)
{