-
-
Notifications
You must be signed in to change notification settings - Fork 479
Closed
Labels
Description
I think it would be nice to add the to_underlying function that was added C++23. I've implemented it locally on my C++14 codebase and figured it could be useful here.
#include <type_traits>
/**
* @brief Converts an enum class value to it's underlying type'd value.
*
* @tparam Enum: Enum class type.
* @param e: Enum class value.
* @return constexpr auto
*/
template <typename Enum>
constexpr auto to_underlying(const Enum e) noexcept ->
typename std::underlying_type_t<Enum>
{
return static_cast<typename std::underlying_type_t<Enum>>(e);
}Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done