mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
EnumUtils: Add Common::ToUnderlying
Mirrors the C++23 <utility> function, std::to_underlying
This commit is contained in:
15
Source/Core/Common/EnumUtils.h
Normal file
15
Source/Core/Common/EnumUtils.h
Normal 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
|
Reference in New Issue
Block a user