feat(Core/Util): AsUnderlyingType (#6117)
* Add AsUnderlyingType function to cast enum value to its underlying type (avoids repeating std::underlying_type everywhere) (cherry picked from commit https://github.com/TrinityCore/TrinityCore/commit/fdd9227b232db9aae9bc4b2c60ca4de2cdaa0b54) Co-Authored-By: Shauren <shauren.trinity@gmail.com>
This commit is contained in:
@@ -892,4 +892,11 @@ private:
|
|||||||
EventStore _eventMap;
|
EventStore _eventMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename E>
|
||||||
|
typename std::underlying_type<E>::type AsUnderlyingType(E enumValue)
|
||||||
|
{
|
||||||
|
static_assert(std::is_enum<E>::value, "AsUnderlyingType can only be used with enums");
|
||||||
|
return static_cast<typename std::underlying_type<E>::type>(enumValue);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user