mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-05 19:51:45 +00:00
sf: fix OutArray/InArray constructors to behave as expected
This commit is contained in:
parent
612d846132
commit
8b19fdfd51
1 changed files with 18 additions and 8 deletions
|
@ -191,10 +191,7 @@ namespace ams::sf {
|
||||||
public:
|
public:
|
||||||
constexpr InArrayImpl() : BaseType() { /* ... */ }
|
constexpr InArrayImpl() : BaseType() { /* ... */ }
|
||||||
constexpr InArrayImpl(const cmif::PointerAndSize &_pas) : BaseType(_pas) { /* ... */ }
|
constexpr InArrayImpl(const cmif::PointerAndSize &_pas) : BaseType(_pas) { /* ... */ }
|
||||||
constexpr InArrayImpl(uintptr_t ptr, size_t sz) : BaseType(ptr, sz) { /* ... */ }
|
constexpr InArrayImpl(const T *ptr, size_t num_elements) : BaseType(reinterpret_cast<uintptr_t>(ptr), num_elements * sizeof(T)) { /* ... */ }
|
||||||
|
|
||||||
constexpr InArrayImpl(const void *ptr, size_t sz) : BaseType(reinterpret_cast<uintptr_t>(ptr), sz) { /* ... */ }
|
|
||||||
constexpr InArrayImpl(const T *ptr, size_t sz) : BaseType(reinterpret_cast<uintptr_t>(ptr), sz) { /* ... */ }
|
|
||||||
|
|
||||||
constexpr const T *GetPointer() const {
|
constexpr const T *GetPointer() const {
|
||||||
return reinterpret_cast<const T *>(this->GetAddressImpl());
|
return reinterpret_cast<const T *>(this->GetAddressImpl());
|
||||||
|
@ -207,6 +204,14 @@ namespace ams::sf {
|
||||||
constexpr const T &operator[](size_t i) const {
|
constexpr const T &operator[](size_t i) const {
|
||||||
return this->GetPointer()[i];
|
return this->GetPointer()[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr explicit operator Span<const T>() const {
|
||||||
|
return {this->GetPointer(), static_cast<ptrdiff_t>(this->GetSize())};
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr Span<const T> ToSpan() const {
|
||||||
|
return {this->GetPointer(), static_cast<ptrdiff_t>(this->GetSize())};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, BufferTransferMode TMode = PreferredTransferMode<T>>
|
template<typename T, BufferTransferMode TMode = PreferredTransferMode<T>>
|
||||||
|
@ -218,10 +223,7 @@ namespace ams::sf {
|
||||||
public:
|
public:
|
||||||
constexpr OutArrayImpl() : BaseType() { /* ... */ }
|
constexpr OutArrayImpl() : BaseType() { /* ... */ }
|
||||||
constexpr OutArrayImpl(const cmif::PointerAndSize &_pas) : BaseType(_pas) { /* ... */ }
|
constexpr OutArrayImpl(const cmif::PointerAndSize &_pas) : BaseType(_pas) { /* ... */ }
|
||||||
constexpr OutArrayImpl(uintptr_t ptr, size_t sz) : BaseType(ptr, sz) { /* ... */ }
|
constexpr OutArrayImpl(T *ptr, size_t num_elements) : BaseType(reinterpret_cast<uintptr_t>(ptr), num_elements * sizeof(T)) { /* ... */ }
|
||||||
|
|
||||||
constexpr OutArrayImpl(void *ptr, size_t sz) : BaseType(reinterpret_cast<uintptr_t>(ptr), sz) { /* ... */ }
|
|
||||||
constexpr OutArrayImpl(T *ptr, size_t sz) : BaseType(reinterpret_cast<uintptr_t>(ptr), sz) { /* ... */ }
|
|
||||||
|
|
||||||
constexpr T *GetPointer() const {
|
constexpr T *GetPointer() const {
|
||||||
return reinterpret_cast<T *>(this->GetAddressImpl());
|
return reinterpret_cast<T *>(this->GetAddressImpl());
|
||||||
|
@ -234,6 +236,14 @@ namespace ams::sf {
|
||||||
constexpr T &operator[](size_t i) const {
|
constexpr T &operator[](size_t i) const {
|
||||||
return this->GetPointer()[i];
|
return this->GetPointer()[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr explicit operator Span<T>() const {
|
||||||
|
return {this->GetPointer(), static_cast<ptrdiff_t>(this->GetSize())};
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr Span<T> ToSpan() const {
|
||||||
|
return {this->GetPointer(), static_cast<ptrdiff_t>(this->GetSize())};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue