EnumUtils: Add Common::ToUnderlying

Mirrors the C++23 <utility> function, std::to_underlying
This commit is contained in:
get
2023-06-17 00:08:07 -05:00
parent 5029924ba1
commit 07ad75f34f
22 changed files with 118 additions and 78 deletions

View File

@ -0,0 +1,15 @@
// SPDX-License-Identifier: CC0-1.0
#pragma once
#include <type_traits>
namespace Common
{
// TODO: Replace with std::to_underlying in C++23
template <typename Enum>
constexpr std::underlying_type_t<Enum> ToUnderlying(Enum e) noexcept
{
return static_cast<std::underlying_type_t<Enum>>(e);
}
} // namespace Common