mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-25 07:09:48 -06:00
EnumUtils: Add Common::ToUnderlying
Mirrors the C++23 <utility> function, std::to_underlying
This commit is contained in:
@ -42,6 +42,7 @@ add_library(common
|
||||
ENet.h
|
||||
EnumFormatter.h
|
||||
EnumMap.h
|
||||
EnumUtils.h
|
||||
Event.h
|
||||
FatFsUtil.cpp
|
||||
FatFsUtil.h
|
||||
|
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