mirror of
https://github.com/CraftyBoss/SuperMarioOdysseyOnline.git
synced 2024-11-28 14:13:04 +00:00
26 lines
667 B
C++
26 lines
667 B
C++
#pragma once
|
|
|
|
#include <type_traits>
|
|
|
|
namespace sead
|
|
{
|
|
/// For storing an enum with a particular storage size when specifying the underlying type of the
|
|
/// enum is not an option.
|
|
template <typename Enum, typename Storage>
|
|
struct SizedEnum
|
|
{
|
|
static_assert(std::is_enum<Enum>());
|
|
static_assert(!std::is_enum<Storage>());
|
|
|
|
constexpr SizedEnum() = default;
|
|
constexpr SizedEnum(Enum value) { *this = value; }
|
|
constexpr operator Enum() const { return static_cast<Enum>(mValue); }
|
|
constexpr SizedEnum& operator=(Enum value)
|
|
{
|
|
mValue = static_cast<Storage>(value);
|
|
return *this;
|
|
}
|
|
|
|
Storage mValue;
|
|
};
|
|
} // namespace sead
|