mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-30 20:58:54 +00:00
EnumUtils: Add Common::ToUnderlying
Mirrors the C++23 <utility> function, std::to_underlying
This commit is contained in:
parent
5029924ba1
commit
07ad75f34f
22 changed files with 118 additions and 78 deletions
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue