SuperMarioOdysseyOnline/include/sead/prim/seadSizedEnum.h
2022-06-16 14:33:18 -07:00

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