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:
Kitzunu
2021-05-30 03:46:04 +02:00
committed by GitHub
parent c74bb4b88a
commit a9ed64e600
+7
View File
@@ -892,4 +892,11 @@ private:
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