mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-30 02:32:46 +01:00
Merge pull request #741 from lioncash/enum
ipc_helpers: Add PushEnum() member function to ResponseBuilder
This commit is contained in:
commit
3acd6fa086
1 changed files with 19 additions and 0 deletions
|
@ -174,6 +174,25 @@ public:
|
||||||
template <typename First, typename... Other>
|
template <typename First, typename... Other>
|
||||||
void Push(const First& first_value, const Other&... other_values);
|
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
|
* @brief Copies the content of the given trivially copyable class to the buffer as a normal
|
||||||
* param
|
* param
|
||||||
|
|
Loading…
Reference in a new issue