diff --git a/libraries/libstratosphere/include/stratosphere/sf/sf_buffers.hpp b/libraries/libstratosphere/include/stratosphere/sf/sf_buffers.hpp index 76f62a4ea..24d9dc526 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/sf_buffers.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/sf_buffers.hpp @@ -191,10 +191,7 @@ namespace ams::sf { public: constexpr InArrayImpl() : BaseType() { /* ... */ } constexpr InArrayImpl(const cmif::PointerAndSize &_pas) : BaseType(_pas) { /* ... */ } - constexpr InArrayImpl(uintptr_t ptr, size_t sz) : BaseType(ptr, sz) { /* ... */ } - - constexpr InArrayImpl(const void *ptr, size_t sz) : BaseType(reinterpret_cast(ptr), sz) { /* ... */ } - constexpr InArrayImpl(const T *ptr, size_t sz) : BaseType(reinterpret_cast(ptr), sz) { /* ... */ } + constexpr InArrayImpl(const T *ptr, size_t num_elements) : BaseType(reinterpret_cast(ptr), num_elements * sizeof(T)) { /* ... */ } constexpr const T *GetPointer() const { return reinterpret_cast(this->GetAddressImpl()); @@ -207,6 +204,14 @@ namespace ams::sf { constexpr const T &operator[](size_t i) const { return this->GetPointer()[i]; } + + constexpr explicit operator Span() const { + return {this->GetPointer(), static_cast(this->GetSize())}; + } + + constexpr Span ToSpan() const { + return {this->GetPointer(), static_cast(this->GetSize())}; + } }; template> @@ -218,10 +223,7 @@ namespace ams::sf { public: constexpr OutArrayImpl() : BaseType() { /* ... */ } constexpr OutArrayImpl(const cmif::PointerAndSize &_pas) : BaseType(_pas) { /* ... */ } - constexpr OutArrayImpl(uintptr_t ptr, size_t sz) : BaseType(ptr, sz) { /* ... */ } - - constexpr OutArrayImpl(void *ptr, size_t sz) : BaseType(reinterpret_cast(ptr), sz) { /* ... */ } - constexpr OutArrayImpl(T *ptr, size_t sz) : BaseType(reinterpret_cast(ptr), sz) { /* ... */ } + constexpr OutArrayImpl(T *ptr, size_t num_elements) : BaseType(reinterpret_cast(ptr), num_elements * sizeof(T)) { /* ... */ } constexpr T *GetPointer() const { return reinterpret_cast(this->GetAddressImpl()); @@ -234,6 +236,14 @@ namespace ams::sf { constexpr T &operator[](size_t i) const { return this->GetPointer()[i]; } + + constexpr explicit operator Span() const { + return {this->GetPointer(), static_cast(this->GetSize())}; + } + + constexpr Span ToSpan() const { + return {this->GetPointer(), static_cast(this->GetSize())}; + } }; }