summaryrefslogtreecommitdiff
path: root/Source/Core/Common
diff options
context:
space:
mode:
authorJoshua Vandaƫle <joshua@vandaele.software>2026-01-09 23:49:10 +0100
committerJoshua Vandaƫle <joshua@vandaele.software>2026-01-09 23:49:10 +0100
commit55f0715ad4edf4485bc7b35e49fbd883ce760e47 (patch)
tree2b016eb261d2138a56c00a682abfefa96174a696 /Source/Core/Common
parentcc0ce62e7ff283919c95c12a1c8e3b0887271690 (diff)
c++23: Replace Common::ToUnderlying with std::to_underlying
Requires at least GCC 11, Clang 13, MSVC 19.30 (VS2022 17.0), or AppleClang 13.1.6 (XCode 13.3).
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.