diff options
author | Lioncash <mathew1800@gmail.com> | 2018-07-20 20:49:13 +0200 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2018-07-20 21:00:58 +0200 |
commit | 0a0b3c4b9ff55020ef490106ff8f1d12c8f122e4 (patch) | |
tree | 35e7886a5d09f822badff4efa4f617e214a57cee | |
parent | Merge pull request #740 from Subv/acc_crash (diff) | |
download | yuzu-0a0b3c4b9ff55020ef490106ff8f1d12c8f122e4.tar yuzu-0a0b3c4b9ff55020ef490106ff8f1d12c8f122e4.tar.gz yuzu-0a0b3c4b9ff55020ef490106ff8f1d12c8f122e4.tar.bz2 yuzu-0a0b3c4b9ff55020ef490106ff8f1d12c8f122e4.tar.lz yuzu-0a0b3c4b9ff55020ef490106ff8f1d12c8f122e4.tar.xz yuzu-0a0b3c4b9ff55020ef490106ff8f1d12c8f122e4.tar.zst yuzu-0a0b3c4b9ff55020ef490106ff8f1d12c8f122e4.zip |
-rw-r--r-- | src/core/hle/ipc_helpers.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h index 24605a273..8b5b06f31 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/ipc_helpers.h @@ -175,6 +175,25 @@ public: void Push(const First& first_value, const Other&... other_values); /** + * Helper function for pushing strongly-typed enumeration values. + * + * @tparam Enum The enumeration type to be pushed + * + * @param value The value to push. + * + * @note The underlying size of the enumeration type is the size of the + * data that gets pushed. e.g. "enum class SomeEnum : u16" will + * push a u16-sized amount of data. + */ + template <typename Enum> + void PushEnum(Enum value) { + static_assert(std::is_enum_v<Enum>, "T must be an enum type within a PushEnum call."); + static_assert(!std::is_convertible_v<Enum, int>, + "enum type in PushEnum must be a strongly typed enum."); + Push(static_cast<std::underlying_type_t<Enum>>(value)); + } + + /** * @brief Copies the content of the given trivially copyable class to the buffer as a normal * param * @note: The input class must be correctly packed/padded to fit hardware layout. |