summaryrefslogtreecommitdiff
path: root/Source/Core/Common
diff options
context:
space:
mode:
authoriwubcode <iwubcode@users.noreply.github.com>2026-01-17 16:49:57 -0600
committerGitHub <noreply@github.com>2026-01-17 16:49:57 -0600
commitb556bd99d72d996364f423b663af5d02a9610c4f (patch)
tree9942d30854cbe59a390221087486ab64254e9ba7 /Source/Core/Common
parent8a606fca88a81b5a24d8cc53e5eaba91f2e38fbd (diff)
parent55f0715ad4edf4485bc7b35e49fbd883ce760e47 (diff)
Merge pull request #14268 from JoshuaVandaele/std-tounderlying
c++23: Replace Common::ToUnderlying with std::to_underlying
Diffstat (limited to 'Source/Core/Common')
-rw-r--r--Source/Core/Common/BitUtils.h6
-rw-r--r--Source/Core/Common/CMakeLists.txt1
-rw-r--r--Source/Core/Common/EnumUtils.h15
-rw-r--r--Source/Core/Common/SFMLHelper.h5
-rw-r--r--Source/Core/Common/StringUtil.h4
5 files changed, 8 insertions, 23 deletions
diff --git a/Source/Core/Common/BitUtils.h b/Source/Core/Common/BitUtils.h
index 9385b9d8d9..19eea49486 100644
--- a/Source/Core/Common/BitUtils.h
+++ b/Source/Core/Common/BitUtils.h
@@ -11,9 +11,9 @@
#include <initializer_list>
#include <span>
#include <type_traits>
+#include <utility>
#include "Common/CommonTypes.h"
-#include "Common/EnumUtils.h"
namespace Common
{
@@ -237,8 +237,8 @@ public:
m_hex |= static_cast<std::underlying_type_t<T>>(bit);
}
}
- auto operator[](T bit) { return FlagBit(&m_hex, Common::ToUnderlying(bit)); }
- auto operator[](T bit) const { return FlagBit(&m_hex, Common::ToUnderlying(bit)); }
+ auto operator[](T bit) { return FlagBit(&m_hex, std::to_underlying(bit)); }
+ auto operator[](T bit) const { return FlagBit(&m_hex, std::to_underlying(bit)); }
std::underlying_type_t<T> m_hex = 0;
};
diff --git a/Source/Core/Common/CMakeLists.txt b/Source/Core/Common/CMakeLists.txt
index 33a03729ca..a1d6d4a80e 100644
--- a/Source/Core/Common/CMakeLists.txt
+++ b/Source/Core/Common/CMakeLists.txt
@@ -60,7 +60,6 @@ add_library(common
ENet.h
EnumFormatter.h
EnumMap.h
- EnumUtils.h
Event.h
FatFsUtil.cpp
FatFsUtil.h
diff --git a/Source/Core/Common/EnumUtils.h b/Source/Core/Common/EnumUtils.h
deleted file mode 100644
index 1a13f59dae..0000000000
--- a/Source/Core/Common/EnumUtils.h
+++ /dev/null
@@ -1,15 +0,0 @@
-// 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
diff --git a/Source/Core/Common/SFMLHelper.h b/Source/Core/Common/SFMLHelper.h
index f3bf968823..7f6e32ef78 100644
--- a/Source/Core/Common/SFMLHelper.h
+++ b/Source/Core/Common/SFMLHelper.h
@@ -5,8 +5,9 @@
#include <SFML/Network/Packet.hpp>
+#include <utility>
+
#include "Common/CommonTypes.h"
-#include "Common/EnumUtils.h"
#include "Common/Swap.h"
#include "Common/TypeUtils.h"
@@ -17,7 +18,7 @@ sf::Packet& operator>>(sf::Packet& packet, Common::BigEndianValue<u64>& data);
template <Common::Enum Enum>
sf::Packet& operator<<(sf::Packet& packet, Enum e)
{
- packet << Common::ToUnderlying(e);
+ packet << std::to_underlying(e);
return packet;
}
diff --git a/Source/Core/Common/StringUtil.h b/Source/Core/Common/StringUtil.h
index 2351c3f720..9a1ddcba16 100644
--- a/Source/Core/Common/StringUtil.h
+++ b/Source/Core/Common/StringUtil.h
@@ -16,10 +16,10 @@
#include <sstream>
#include <string>
#include <type_traits>
+#include <utility>
#include <vector>
#include "Common/CommonTypes.h"
-#include "Common/EnumUtils.h"
#include "Common/TypeUtils.h"
std::string StringFromFormatV(const char* format, va_list args);
@@ -157,7 +157,7 @@ std::string ValueToString(s64 value);
std::string ValueToString(bool value);
std::string ValueToString(Common::Enum auto value)
{
- return ValueToString(Common::ToUnderlying(value));
+ return ValueToString(std::to_underlying(value));
}
// Generates an hexdump-like representation of a binary data blob.