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 fdd9227b23)
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

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