diff --git a/app/src/main/cpp/skyline/common/utils.h b/app/src/main/cpp/skyline/common/utils.h index b37f124d..c7a2c22c 100644 --- a/app/src/main/cpp/skyline/common/utils.h +++ b/app/src/main/cpp/skyline/common/utils.h @@ -55,7 +55,7 @@ namespace skyline::util { return static_cast(item); } - template + template concept IsPointerOrUnsignedIntegral = (std::is_unsigned_v && std::is_integral_v) || std::is_pointer_v; /** @@ -231,4 +231,24 @@ namespace skyline::util { To BitCast(const From &from) { return *reinterpret_cast(&from); } + + /** + * @brief A utility type for placing elements by offset in unions rather than relative position in structs + * @tparam PadType The type of a unit of padding, total size of padding is `sizeof(PadType) * Offset` + */ + template + struct OffsetMember { + private: + PadType _pad_[Offset]; + ValueType value; + + public: + ValueType &operator*() { + return value; + } + + ValueType *operator->() { + return &value; + } + }; }