From 55f0715ad4edf4485bc7b35e49fbd883ce760e47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Vanda=C3=ABle?= Date: Fri, 9 Jan 2026 23:49:10 +0100 Subject: [PATCH] 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). --- CMakeLists.txt | 4 +- Source/Android/jni/GpuDriver.cpp | 5 ++- Source/Core/Common/BitUtils.h | 6 +-- Source/Core/Common/CMakeLists.txt | 1 - Source/Core/Common/EnumUtils.h | 15 ------- Source/Core/Common/SFMLHelper.h | 5 ++- Source/Core/Common/StringUtil.h | 4 +- Source/Core/Core/DSP/DSPDisassembler.cpp | 5 +-- .../Core/Core/DSP/Jit/x64/DSPJitRegCache.cpp | 40 +++++++++---------- Source/Core/Core/Debugger/BranchWatch.h | 10 ++--- Source/Core/Core/DolphinAnalytics.cpp | 4 +- .../Core/HW/WiimoteEmu/EmuSubroutines.cpp | 4 +- Source/Core/Core/IOS/ES/ES.cpp | 13 +++--- Source/Core/Core/IOS/ES/Identity.cpp | 10 ++--- Source/Core/Core/IOS/ES/TitleManagement.cpp | 8 ++-- Source/Core/Core/IOS/FS/FileSystemProxy.cpp | 4 +- Source/Core/Core/IOS/IOS.cpp | 7 ++-- .../Core/Core/IOS/Network/KD/VFF/VFFUtil.cpp | 4 +- Source/Core/Core/IOS/Network/Socket.h | 3 +- .../Core/IOS/USB/Emulated/LogitechMic.cpp | 19 ++++----- Source/Core/Core/IOS/WFS/WFSI.cpp | 3 +- Source/Core/Core/PowerPC/Jit64/Jit.cpp | 4 +- Source/Core/Core/PowerPC/Jit64/JitAsm.cpp | 6 +-- .../PowerPC/Jit64/RegCache/JitRegCache.cpp | 11 +++-- .../PowerPC/Jit64Common/Jit64AsmCommon.cpp | 6 +-- Source/Core/Core/PowerPC/JitArm64/Jit.cpp | 4 +- Source/Core/Core/PowerPC/JitArm64/JitAsm.cpp | 6 +-- Source/Core/Core/WiiUtils.cpp | 11 +++-- Source/Core/DolphinLib.props | 1 - .../Config/Graphics/EnhancementsWidget.cpp | 19 ++++----- .../Core/DolphinQt/Config/SettingsWindow.cpp | 6 +-- Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp | 4 +- Source/Core/VideoBackends/Vulkan/VKGfx.cpp | 8 ++-- Source/Core/VideoCommon/CPMemory.cpp | 10 ++--- .../Resources/MaterialResource.cpp | 4 +- Source/Core/VideoCommon/TextureCacheBase.cpp | 3 +- Source/Core/VideoCommon/UberShaderCommon.cpp | 7 ++-- Source/Core/VideoCommon/UberShaderVertex.cpp | 31 +++++++------- 38 files changed, 148 insertions(+), 167 deletions(-) delete mode 100644 Source/Core/Common/EnumUtils.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f432b77bba..607ba8ba178 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,12 +38,12 @@ if (COMPILER STREQUAL "GNU") set(COMPILER "GCC") # prefer printing GCC instead of GNU endif() -# Enforce minimum compiler versions that support the c++20 features we use +# Enforce minimum compiler versions that support the c++23 features we use set (GCC_min_version 11) set (Clang_min_version 14) set (AppleClang_min_version 14.0.3) set (min_xcode_version "14.0") # corresponding xcode version for AppleClang_min_version -set (MSVC_min_version 14.32) +set (MSVC_min_version 19.30) set (min_vs_version "2022 17.2.3") # corresponding Visual Studio version for MSVC_min_version message(STATUS "Using ${COMPILER} ${CMAKE_CXX_COMPILER_VERSION}") diff --git a/Source/Android/jni/GpuDriver.cpp b/Source/Android/jni/GpuDriver.cpp index cff81691e72..de37ab8d403 100644 --- a/Source/Android/jni/GpuDriver.cpp +++ b/Source/Android/jni/GpuDriver.cpp @@ -7,7 +7,8 @@ #include -#include "Common/EnumUtils.h" +#include + #include "Common/IniFile.h" #include "jni/AndroidCommon/AndroidCommon.h" #include "jni/AndroidCommon/IDCache.h" @@ -70,7 +71,7 @@ Java_org_dolphinemu_dolphinemu_utils_GpuDriverHelper_00024Companion_getSystemDri properties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2; properties2.pNext = &driverProperties; vkGetPhysicalDeviceProperties2(gpu_list.front(), &properties2); - driverId = fmt::format("{}", Common::ToUnderlying(driverProperties.driverID)); + driverId = fmt::format("{}", std::to_underlying(driverProperties.driverID)); } else { diff --git a/Source/Core/Common/BitUtils.h b/Source/Core/Common/BitUtils.h index 9385b9d8d94..19eea494860 100644 --- a/Source/Core/Common/BitUtils.h +++ b/Source/Core/Common/BitUtils.h @@ -11,9 +11,9 @@ #include #include #include +#include #include "Common/CommonTypes.h" -#include "Common/EnumUtils.h" namespace Common { @@ -237,8 +237,8 @@ public: m_hex |= static_cast>(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 m_hex = 0; }; diff --git a/Source/Core/Common/CMakeLists.txt b/Source/Core/Common/CMakeLists.txt index 33a03729ca4..a1d6d4a80e7 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 1a13f59dae8..00000000000 --- a/Source/Core/Common/EnumUtils.h +++ /dev/null @@ -1,15 +0,0 @@ -// SPDX-License-Identifier: CC0-1.0 - -#pragma once - -#include - -namespace Common -{ -// TODO: Replace with std::to_underlying in C++23 -template -constexpr std::underlying_type_t ToUnderlying(Enum e) noexcept -{ - return static_cast>(e); -} -} // namespace Common diff --git a/Source/Core/Common/SFMLHelper.h b/Source/Core/Common/SFMLHelper.h index f3bf9688237..7f6e32ef785 100644 --- a/Source/Core/Common/SFMLHelper.h +++ b/Source/Core/Common/SFMLHelper.h @@ -5,8 +5,9 @@ #include +#include + #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& data); template 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 2351c3f7206..9a1ddcba163 100644 --- a/Source/Core/Common/StringUtil.h +++ b/Source/Core/Common/StringUtil.h @@ -16,10 +16,10 @@ #include #include #include +#include #include #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. diff --git a/Source/Core/Core/DSP/DSPDisassembler.cpp b/Source/Core/Core/DSP/DSPDisassembler.cpp index c0d2d37848c..3a4b77c39d5 100644 --- a/Source/Core/Core/DSP/DSPDisassembler.cpp +++ b/Source/Core/Core/DSP/DSPDisassembler.cpp @@ -7,12 +7,12 @@ #include #include #include +#include #include #include #include "Common/CommonTypes.h" -#include "Common/EnumUtils.h" #include "Common/Logging/Log.h" #include "Common/StringUtil.h" @@ -133,8 +133,7 @@ std::string DSPDisassembler::DisassembleParameters(const DSPOPCTemplate& opc, u1 break; default: - ERROR_LOG_FMT(DSPLLE, "Unknown parameter type: {:x}", - Common::ToUnderlying(opc.params[j].type)); + ERROR_LOG_FMT(DSPLLE, "Unknown parameter type: {:x}", std::to_underlying(opc.params[j].type)); break; } } diff --git a/Source/Core/Core/DSP/Jit/x64/DSPJitRegCache.cpp b/Source/Core/Core/DSP/Jit/x64/DSPJitRegCache.cpp index 47a011e9b47..f8f9c9c19f5 100644 --- a/Source/Core/Core/DSP/Jit/x64/DSPJitRegCache.cpp +++ b/Source/Core/Core/DSP/Jit/x64/DSPJitRegCache.cpp @@ -4,9 +4,9 @@ #include "Core/DSP/Jit/x64/DSPJitRegCache.h" #include +#include #include "Common/Assert.h" -#include "Common/EnumUtils.h" #include "Common/Logging/Log.h" #include "Core/DSP/DSPCore.h" @@ -367,38 +367,38 @@ void DSPJitRegCache::FlushRegs() } ASSERT_MSG(DSPLLE, m_xregs[RSP].guest_reg == DSP_REG_STATIC, "wrong xreg state for {}", - Common::ToUnderlying(RSP)); + std::to_underlying(RSP)); ASSERT_MSG(DSPLLE, m_xregs[RBX].guest_reg == DSP_REG_STATIC, "wrong xreg state for {}", - Common::ToUnderlying(RBX)); + std::to_underlying(RBX)); ASSERT_MSG(DSPLLE, m_xregs[RBP].guest_reg == DSP_REG_NONE, "wrong xreg state for {}", - Common::ToUnderlying(RBP)); + std::to_underlying(RBP)); ASSERT_MSG(DSPLLE, m_xregs[RSI].guest_reg == DSP_REG_NONE, "wrong xreg state for {}", - Common::ToUnderlying(RSI)); + std::to_underlying(RSI)); ASSERT_MSG(DSPLLE, m_xregs[RDI].guest_reg == DSP_REG_NONE, "wrong xreg state for {}", - Common::ToUnderlying(RDI)); + std::to_underlying(RDI)); #ifdef STATIC_REG_ACCS ASSERT_MSG(DSPLLE, m_xregs[R8].guest_reg == DSP_REG_STATIC, "wrong xreg state for {}", - Common::ToUnderlying(R8)); + std::to_underlying(R8)); ASSERT_MSG(DSPLLE, m_xregs[R9].guest_reg == DSP_REG_STATIC, "wrong xreg state for {}", - Common::ToUnderlying(R9)); + std::to_underlying(R9)); #else ASSERT_MSG(DSPLLE, m_xregs[R8].guest_reg == DSP_REG_NONE, "wrong xreg state for {}", - Common::ToUnderlying(R8)); + std::to_underlying(R8)); ASSERT_MSG(DSPLLE, m_xregs[R9].guest_reg == DSP_REG_NONE, "wrong xreg state for {}", - Common::ToUnderlying(R9)); + std::to_underlying(R9)); #endif ASSERT_MSG(DSPLLE, m_xregs[R10].guest_reg == DSP_REG_NONE, "wrong xreg state for {}", - Common::ToUnderlying(R10)); + std::to_underlying(R10)); ASSERT_MSG(DSPLLE, m_xregs[R11].guest_reg == DSP_REG_NONE, "wrong xreg state for {}", - Common::ToUnderlying(R11)); + std::to_underlying(R11)); ASSERT_MSG(DSPLLE, m_xregs[R12].guest_reg == DSP_REG_NONE, "wrong xreg state for {}", - Common::ToUnderlying(R12)); + std::to_underlying(R12)); ASSERT_MSG(DSPLLE, m_xregs[R13].guest_reg == DSP_REG_NONE, "wrong xreg state for {}", - Common::ToUnderlying(R13)); + std::to_underlying(R13)); ASSERT_MSG(DSPLLE, m_xregs[R14].guest_reg == DSP_REG_NONE, "wrong xreg state for {}", - Common::ToUnderlying(R14)); + std::to_underlying(R14)); ASSERT_MSG(DSPLLE, m_xregs[R15].guest_reg == DSP_REG_STATIC, "wrong xreg state for {}", - Common::ToUnderlying(R15)); + std::to_underlying(R15)); m_use_ctr = 0; } @@ -985,14 +985,14 @@ void DSPJitRegCache::SpillXReg(X64Reg reg) { ASSERT_MSG(DSPLLE, !m_regs[m_xregs[reg].guest_reg].used, "to be spilled host reg {:#x} (guest reg {:#x}) still in use!", - Common::ToUnderlying(reg), m_xregs[reg].guest_reg); + std::to_underlying(reg), m_xregs[reg].guest_reg); MovToMemory(m_xregs[reg].guest_reg); } else { ASSERT_MSG(DSPLLE, m_xregs[reg].guest_reg == DSP_REG_NONE, - "to be spilled host reg {:#x} still in use!", Common::ToUnderlying(reg)); + "to be spilled host reg {:#x} still in use!", std::to_underlying(reg)); } } @@ -1037,7 +1037,7 @@ void DSPJitRegCache::GetXReg(X64Reg reg) { if (m_xregs[reg].guest_reg == DSP_REG_STATIC) { - ERROR_LOG_FMT(DSPLLE, "Trying to get statically used XReg {}", Common::ToUnderlying(reg)); + ERROR_LOG_FMT(DSPLLE, "Trying to get statically used XReg {}", std::to_underlying(reg)); return; } @@ -1053,7 +1053,7 @@ void DSPJitRegCache::PutXReg(X64Reg reg) { if (m_xregs[reg].guest_reg == DSP_REG_STATIC) { - ERROR_LOG_FMT(DSPLLE, "Trying to put statically used XReg {}", Common::ToUnderlying(reg)); + ERROR_LOG_FMT(DSPLLE, "Trying to put statically used XReg {}", std::to_underlying(reg)); return; } diff --git a/Source/Core/Core/Debugger/BranchWatch.h b/Source/Core/Core/Debugger/BranchWatch.h index d15af60a03b..cbf8dbd5c25 100644 --- a/Source/Core/Core/Debugger/BranchWatch.h +++ b/Source/Core/Core/Debugger/BranchWatch.h @@ -8,10 +8,10 @@ #include #include #include +#include #include #include "Common/CommonTypes.h" -#include "Common/EnumUtils.h" #include "Core/PowerPC/Gekko.h" namespace Core @@ -71,15 +71,15 @@ enum class BranchWatchSelectionInspection : u8 constexpr BranchWatchSelectionInspection operator|(BranchWatchSelectionInspection lhs, BranchWatchSelectionInspection rhs) { - return static_cast(Common::ToUnderlying(lhs) | - Common::ToUnderlying(rhs)); + return static_cast(std::to_underlying(lhs) | + std::to_underlying(rhs)); } constexpr BranchWatchSelectionInspection operator&(BranchWatchSelectionInspection lhs, BranchWatchSelectionInspection rhs) { - return static_cast(Common::ToUnderlying(lhs) & - Common::ToUnderlying(rhs)); + return static_cast(std::to_underlying(lhs) & + std::to_underlying(rhs)); } constexpr BranchWatchSelectionInspection& operator|=(BranchWatchSelectionInspection& self, diff --git a/Source/Core/Core/DolphinAnalytics.cpp b/Source/Core/Core/DolphinAnalytics.cpp index 01aece16796..8b207c658c2 100644 --- a/Source/Core/Core/DolphinAnalytics.cpp +++ b/Source/Core/Core/DolphinAnalytics.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -27,7 +28,6 @@ #include "Common/CommonTypes.h" #include "Common/Config/Config.h" #include "Common/Crypto/SHA1.h" -#include "Common/EnumUtils.h" #include "Common/Random.h" #include "Common/Timer.h" #include "Common/Version.h" @@ -396,7 +396,7 @@ void DolphinAnalytics::MakePerGameBuilder() builder.AddData("cfg-gfx-multisamples", Config::Get(Config::GFX_MSAA)); builder.AddData("cfg-gfx-ssaa", Config::Get(Config::GFX_SSAA)); builder.AddData("cfg-gfx-anisotropy", - Common::ToUnderlying(Config::Get(Config::GFX_ENHANCE_MAX_ANISOTROPY))); + std::to_underlying(Config::Get(Config::GFX_ENHANCE_MAX_ANISOTROPY))); builder.AddData("cfg-gfx-vsync", Config::Get(Config::GFX_VSYNC)); builder.AddData("cfg-gfx-aspect-ratio", static_cast(Config::Get(Config::GFX_ASPECT_RATIO))); builder.AddData("cfg-gfx-efb-access", Config::Get(Config::GFX_HACK_EFB_ACCESS_ENABLE)); diff --git a/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp b/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp index 46a4c417d8f..e8f9f60bf8e 100644 --- a/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp @@ -5,11 +5,11 @@ #include #include +#include #include "Common/BitUtils.h" #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" -#include "Common/EnumUtils.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" #include "Common/Swap.h" @@ -208,7 +208,7 @@ void Wiimote::HandleExtensionSwap(ExtensionNumber desired_extension_number, else { INFO_LOG_FMT(WIIMOTE, "Switching to Extension {} (Wiimote {} in slot {})", - Common::ToUnderlying(desired_extension_number), m_index, m_bt_device_index); + std::to_underlying(desired_extension_number), m_index, m_bt_device_index); m_active_extension = desired_extension_number; } diff --git a/Source/Core/Core/IOS/ES/ES.cpp b/Source/Core/Core/IOS/ES/ES.cpp index c6cc2e942f8..194d6cc7e0d 100644 --- a/Source/Core/Core/IOS/ES/ES.cpp +++ b/Source/Core/Core/IOS/ES/ES.cpp @@ -12,7 +12,6 @@ #include #include "Common/ChunkFile.h" -#include "Common/EnumUtils.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" #include "Common/NandPaths.h" @@ -96,7 +95,7 @@ ESCore::ESCore(Kernel& ios) : m_ios(ios) if (result != FS::ResultCode::Success && result != FS::ResultCode::AlreadyExists) { ERROR_LOG_FMT(IOS_ES, "Failed to create {}: error {}", directory.path, - Common::ToUnderlying(FS::ConvertResult(result))); + std::to_underlying(FS::ConvertResult(result))); } // Now update the UID/GID and other attributes. @@ -1116,7 +1115,7 @@ ReturnCode ESCore::VerifyContainer(VerifyContainerType type, VerifyMode mode, if (ret != IPC_SUCCESS) { ERROR_LOG_FMT(IOS_ES, "VerifyContainer: IOSC_ImportCertificate(ca) failed with error {}", - Common::ToUnderlying(ret)); + std::to_underlying(ret)); return ret; } @@ -1132,7 +1131,7 @@ ReturnCode ESCore::VerifyContainer(VerifyContainerType type, VerifyMode mode, if (ret != IPC_SUCCESS) { ERROR_LOG_FMT(IOS_ES, "VerifyContainer: IOSC_ImportCertificate(issuer) failed with error {}", - Common::ToUnderlying(ret)); + std::to_underlying(ret)); return ret; } @@ -1142,7 +1141,7 @@ ReturnCode ESCore::VerifyContainer(VerifyContainerType type, VerifyMode mode, if (ret != IPC_SUCCESS) { ERROR_LOG_FMT(IOS_ES, "VerifyContainer: IOSC_VerifyPublicKeySign failed with error {}", - Common::ToUnderlying(ret)); + std::to_underlying(ret)); return ret; } @@ -1152,13 +1151,13 @@ ReturnCode ESCore::VerifyContainer(VerifyContainerType type, VerifyMode mode, if (ret != IPC_SUCCESS) { ERROR_LOG_FMT(IOS_ES, "VerifyContainer: Writing the issuer cert failed with return code {}", - Common::ToUnderlying(ret)); + std::to_underlying(ret)); } ret = WriteNewCertToStore(ca_cert); if (ret != IPC_SUCCESS) ERROR_LOG_FMT(IOS_ES, "VerifyContainer: Writing the CA cert failed with return code {}", - Common::ToUnderlying(ret)); + std::to_underlying(ret)); } if (ret == IPC_SUCCESS && issuer_handle_out) diff --git a/Source/Core/Core/IOS/ES/Identity.cpp b/Source/Core/Core/IOS/ES/Identity.cpp index 454e912f5a8..6bfb8082f32 100644 --- a/Source/Core/Core/IOS/ES/Identity.cpp +++ b/Source/Core/Core/IOS/ES/Identity.cpp @@ -3,11 +3,11 @@ #include "Core/IOS/ES/ES.h" +#include #include #include "Common/Crypto/SHA1.h" #include "Common/Crypto/ec.h" -#include "Common/EnumUtils.h" #include "Common/Logging/Log.h" #include "Common/ScopeGuard.h" #include "Common/StringUtil.h" @@ -165,7 +165,7 @@ ReturnCode ESCore::VerifySign(const std::vector& hash, const std::vector if (ret != IPC_SUCCESS) { ERROR_LOG_FMT(IOS_ES, "VerifySign: VerifyContainer(ng) failed with error {}", - Common::ToUnderlying(ret)); + std::to_underlying(ret)); return ret; } @@ -173,7 +173,7 @@ ReturnCode ESCore::VerifySign(const std::vector& hash, const std::vector if (ret != IPC_SUCCESS) { ERROR_LOG_FMT(IOS_ES, "VerifySign: IOSC_VerifyPublicKeySign(ap) failed with error {}", - Common::ToUnderlying(ret)); + std::to_underlying(ret)); return ret; } @@ -187,7 +187,7 @@ ReturnCode ESCore::VerifySign(const std::vector& hash, const std::vector if (ret != IPC_SUCCESS) { ERROR_LOG_FMT(IOS_ES, "VerifySign: IOSC_ImportPublicKey(ap) failed with error {}", - Common::ToUnderlying(ret)); + std::to_underlying(ret)); return ret; } @@ -196,7 +196,7 @@ ReturnCode ESCore::VerifySign(const std::vector& hash, const std::vector if (ret != IPC_SUCCESS) { ERROR_LOG_FMT(IOS_ES, "VerifySign: IOSC_VerifyPublicKeySign(data) failed with error {}", - Common::ToUnderlying(ret)); + std::to_underlying(ret)); return ret; } diff --git a/Source/Core/Core/IOS/ES/TitleManagement.cpp b/Source/Core/Core/IOS/ES/TitleManagement.cpp index 25e4f3ad660..4474a55f001 100644 --- a/Source/Core/Core/IOS/ES/TitleManagement.cpp +++ b/Source/Core/Core/IOS/ES/TitleManagement.cpp @@ -12,7 +12,6 @@ #include "Common/Align.h" #include "Common/Crypto/SHA1.h" -#include "Common/EnumUtils.h" #include "Common/Logging/Log.h" #include "Common/NandPaths.h" #include "Core/CommonTitles.h" @@ -73,7 +72,7 @@ ReturnCode ESCore::ImportTicket(const std::vector& ticket_bytes, if (ret < 0) { ERROR_LOG_FMT(IOS_ES, "ImportTicket: Failed to unpersonalise ticket for {:016x} ({})", - ticket.GetTitleId(), Common::ToUnderlying(ret)); + ticket.GetTitleId(), std::to_underlying(ret)); return ret; } } @@ -163,7 +162,7 @@ ReturnCode ESCore::ImportTmd(Context& context, const std::vector& tmd_bytes, if (ret != IPC_SUCCESS) { ERROR_LOG_FMT(IOS_ES, "ImportTmd: VerifyContainer failed with error {}", - Common::ToUnderlying(ret)); + std::to_underlying(ret)); return ret; } @@ -177,8 +176,7 @@ ReturnCode ESCore::ImportTmd(Context& context, const std::vector& tmd_bytes, &context.title_import_export.key_handle); if (ret != IPC_SUCCESS) { - ERROR_LOG_FMT(IOS_ES, "ImportTmd: InitBackupKey failed with error {}", - Common::ToUnderlying(ret)); + ERROR_LOG_FMT(IOS_ES, "ImportTmd: InitBackupKey failed with error {}", std::to_underlying(ret)); return ret; } diff --git a/Source/Core/Core/IOS/FS/FileSystemProxy.cpp b/Source/Core/Core/IOS/FS/FileSystemProxy.cpp index f2cb61e1992..628d78d8249 100644 --- a/Source/Core/Core/IOS/FS/FileSystemProxy.cpp +++ b/Source/Core/Core/IOS/FS/FileSystemProxy.cpp @@ -6,11 +6,11 @@ #include #include #include +#include #include #include "Common/ChunkFile.h" -#include "Common/EnumUtils.h" #include "Common/StringUtil.h" #include "Common/Swap.h" #include "Core/HW/Memmap.h" @@ -120,7 +120,7 @@ static void LogResult(ResultCode code, fmt::format_string format, Args& code == ResultCode::Success ? Common::Log::LogLevel::LINFO : Common::Log::LogLevel::LERROR; GENERIC_LOG_FMT(Common::Log::LogType::IOS_FS, type, "Command: {}: Result {}", command, - Common::ToUnderlying(ConvertResult(code))); + std::to_underlying(ConvertResult(code))); } template diff --git a/Source/Core/Core/IOS/IOS.cpp b/Source/Core/Core/IOS/IOS.cpp index 7449ba69bbe..70e63ace228 100644 --- a/Source/Core/Core/IOS/IOS.cpp +++ b/Source/Core/Core/IOS/IOS.cpp @@ -14,7 +14,6 @@ #include "Common/Assert.h" #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" -#include "Common/EnumUtils.h" #include "Common/Logging/Log.h" #include "Common/Timer.h" @@ -662,8 +661,8 @@ std::shared_ptr EmulationKernel::GetDeviceByFileDescriptor(const u32 fd) std::optional EmulationKernel::OpenDevice(OpenRequest& request) { const s32 new_fd = GetFreeDeviceID(); - INFO_LOG_FMT(IOS, "Opening {} (mode {}, fd {})", request.path, - Common::ToUnderlying(request.flags), new_fd); + INFO_LOG_FMT(IOS, "Opening {} (mode {}, fd {})", request.path, std::to_underlying(request.flags), + new_fd); if (new_fd < 0 || new_fd >= IPC_MAX_FDS) { ERROR_LOG_FMT(IOS, "Couldn't get a free fd, too many open files"); @@ -749,7 +748,7 @@ std::optional EmulationKernel::HandleIPCCommand(const Request& request ret = device->IOCtlV(IOCtlVRequest{GetSystem(), request.address}); break; default: - ASSERT_MSG(IOS, false, "Unexpected command: {:#x}", Common::ToUnderlying(request.command)); + ASSERT_MSG(IOS, false, "Unexpected command: {:#x}", std::to_underlying(request.command)); ret = IPCReply{IPC_EINVAL, 978_tbticks}; break; } diff --git a/Source/Core/Core/IOS/Network/KD/VFF/VFFUtil.cpp b/Source/Core/Core/IOS/Network/KD/VFF/VFFUtil.cpp index c7ddffbc157..530d9adb298 100644 --- a/Source/Core/Core/IOS/Network/KD/VFF/VFFUtil.cpp +++ b/Source/Core/Core/IOS/Network/KD/VFF/VFFUtil.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -17,7 +18,6 @@ // clang-format on #include "Common/Align.h" -#include "Common/EnumUtils.h" #include "Common/FatFsUtil.h" #include "Common/Logging/Log.h" #include "Common/ScopeGuard.h" @@ -212,7 +212,7 @@ static ErrorCode WriteFile(const std::string& filename, std::span tmp_ if (write_error_code != FR_OK) { ERROR_LOG_FMT(IOS_WC24, "Failed to write file {} to VFF: {}", filename, - Common::ToUnderlying(write_error_code)); + std::to_underlying(write_error_code)); return WC24_ERR_FILE_WRITE; } diff --git a/Source/Core/Core/IOS/Network/Socket.h b/Source/Core/Core/IOS/Network/Socket.h index abfc752afa5..d339c0282ab 100644 --- a/Source/Core/Core/IOS/Network/Socket.h +++ b/Source/Core/Core/IOS/Network/Socket.h @@ -52,7 +52,6 @@ typedef struct pollfd pollfd_t; #include #include "Common/CommonTypes.h" -#include "Common/EnumUtils.h" #include "Common/Logging/Log.h" #include "Core/HW/Memmap.h" #include "Core/IOS/IOS.h" @@ -291,7 +290,7 @@ public: if (socket_entry == WiiSockets.end()) { ERROR_LOG_FMT(IOS_NET, "DoSock: Error, fd not found ({:08x}, {:08X}, {:08X})", sock, - request.address, Common::ToUnderlying(type)); + request.address, std::to_underlying(type)); EnqueueIPCReply(request, -SO_EBADF); } else diff --git a/Source/Core/Core/IOS/USB/Emulated/LogitechMic.cpp b/Source/Core/Core/IOS/USB/Emulated/LogitechMic.cpp index df161803450..42cc7b1602d 100644 --- a/Source/Core/Core/IOS/USB/Emulated/LogitechMic.cpp +++ b/Source/Core/Core/IOS/USB/Emulated/LogitechMic.cpp @@ -4,6 +4,7 @@ #include "Core/IOS/USB/Emulated/LogitechMic.h" #include +#include #include "Core/Config/MainSettings.h" #include "Core/HW/Memmap.h" @@ -208,12 +209,12 @@ static constexpr u32 USBGETAID(u8 cs, u8 request, u16 index) static constexpr u32 USBGETAID(FeatureUnitControlSelector cs, RequestCode request, u16 index) { - return USBGETAID(Common::ToUnderlying(cs), Common::ToUnderlying(request), index); + return USBGETAID(std::to_underlying(cs), std::to_underlying(request), index); } static constexpr u32 USBGETAID(EndpointControlSelector cs, RequestCode request, u16 index) { - return USBGETAID(Common::ToUnderlying(cs), Common::ToUnderlying(request), index); + return USBGETAID(std::to_underlying(cs), std::to_underlying(request), index); } int LogitechMic::GetAudioControl(std::unique_ptr& cmd) @@ -228,7 +229,7 @@ int LogitechMic::GetAudioControl(std::unique_ptr& cmd) DEBUG_LOG_FMT(IOS_USB, "GetAudioControl: bCs={:02x} bCn={:02x} bRequestType={:02x} bRequest={:02x} " "bIndex={:02x} aid={:08x}", - Common::ToUnderlying(cs), cn, cmd->request_type, Common::ToUnderlying(request), + std::to_underlying(cs), cn, cmd->request_type, std::to_underlying(request), cmd->index, aid); switch (aid) { @@ -281,7 +282,7 @@ int LogitechMic::GetAudioControl(std::unique_ptr& cmd) WARN_LOG_FMT(IOS_USB, "GetAudioControl: Unknown request: bCs={:02x} bCn={:02x} bRequestType={:02x} " "bRequest={:02x} bIndex={:02x} aid={:08x}", - Common::ToUnderlying(cs), cn, cmd->request_type, Common::ToUnderlying(request), + std::to_underlying(cs), cn, cmd->request_type, std::to_underlying(request), cmd->index, aid); break; } @@ -301,7 +302,7 @@ int LogitechMic::SetAudioControl(std::unique_ptr& cmd) DEBUG_LOG_FMT(IOS_USB, "SetAudioControl: bCs={:02x} bCn={:02x} bRequestType={:02x} bRequest={:02x} " "bIndex={:02x} aid={:08x}", - Common::ToUnderlying(cs), cn, cmd->request_type, Common::ToUnderlying(request), + std::to_underlying(cs), cn, cmd->request_type, std::to_underlying(request), cmd->index, aid); switch (aid) { @@ -344,7 +345,7 @@ int LogitechMic::SetAudioControl(std::unique_ptr& cmd) WARN_LOG_FMT(IOS_USB, "SetAudioControl: Unknown request: bCs={:02x} bCn={:02x} bRequestType={:02x} " "bRequest={:02x} bIndex={:02x} aid={:08x}", - Common::ToUnderlying(cs), cn, cmd->request_type, Common::ToUnderlying(request), + std::to_underlying(cs), cn, cmd->request_type, std::to_underlying(request), cmd->index, aid); break; } @@ -364,7 +365,7 @@ int LogitechMic::EndpointAudioControl(std::unique_ptr& cmd) DEBUG_LOG_FMT(IOS_USB, "EndpointAudioControl: bCs={:02x} bCn={:02x} bRequestType={:02x} bRequest={:02x} " "bIndex={:02x} aid:{:08x}", - Common::ToUnderlying(cs), cn, cmd->request_type, Common::ToUnderlying(request), + std::to_underlying(cs), cn, cmd->request_type, std::to_underlying(request), cmd->index, aid); switch (aid) { @@ -406,7 +407,7 @@ int LogitechMic::EndpointAudioControl(std::unique_ptr& cmd) WARN_LOG_FMT(IOS_USB, "SetAudioControl: Unknown request: bCs={:02x} bCn={:02x} bRequestType={:02x} " "bRequest={:02x} bIndex={:02x} aid={:08x}", - Common::ToUnderlying(cs), cn, cmd->request_type, Common::ToUnderlying(request), + std::to_underlying(cs), cn, cmd->request_type, std::to_underlying(request), cmd->index, aid); break; } @@ -544,7 +545,7 @@ static constexpr std::array FULL_DESCRIPTOR = { static constexpr u16 LogitechUSBHDR(u8 dir, u8 type, u8 recipient, RequestCode request) { - return USBHDR(dir, type, recipient, Common::ToUnderlying(request)); + return USBHDR(dir, type, recipient, std::to_underlying(request)); } int LogitechMic::SubmitTransfer(std::unique_ptr cmd) diff --git a/Source/Core/Core/IOS/WFS/WFSI.cpp b/Source/Core/Core/IOS/WFS/WFSI.cpp index d362c3d312b..566956832a4 100644 --- a/Source/Core/Core/IOS/WFS/WFSI.cpp +++ b/Source/Core/Core/IOS/WFS/WFSI.cpp @@ -12,7 +12,6 @@ #include "Common/CommonTypes.h" #include "Common/Crypto/AES.h" -#include "Common/EnumUtils.h" #include "Common/FileUtil.h" #include "Common/IOFile.h" #include "Common/Logging/Log.h" @@ -144,7 +143,7 @@ std::optional WFSIDevice::IOCtl(const IOCtlRequest& request) m_continue_install = memory.Read_U32(request.buffer_in + 36); INFO_LOG_FMT(IOS_WFS, "IOCTL_WFSI_IMPORT_TITLE_INIT: patch type {}, continue install: {}", - Common::ToUnderlying(m_patch_type), m_continue_install ? "true" : "false"); + std::to_underlying(m_patch_type), m_continue_install ? "true" : "false"); if (m_patch_type == PatchType::PATCH_TYPE_2) { diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/PowerPC/Jit64/Jit.cpp index 1cdaf8c55ac..c0eda2f8f51 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -17,7 +18,6 @@ #endif #include "Common/CommonTypes.h" -#include "Common/EnumUtils.h" #include "Common/GekkoDisassembler.h" #include "Common/HostDisassembler.h" #include "Common/IOFile.h" @@ -1071,7 +1071,7 @@ bool Jit64::DoJit(u32 em_address, JitBlock* b, u32 nextPC) ABI_CallFunctionP(PowerPC::CheckAndHandleBreakPointsFromJIT, &power_pc); ABI_PopRegistersAndAdjustStack({}, 0); MOV(64, R(RSCRATCH), ImmPtr(cpu.GetStatePtr())); - CMP(32, MatR(RSCRATCH), Imm32(Common::ToUnderlying(CPU::State::Running))); + CMP(32, MatR(RSCRATCH), Imm32(std::to_underlying(CPU::State::Running))); FixupBranch noBreakpoint = J_CC(CC_E); Cleanup(); diff --git a/Source/Core/Core/PowerPC/Jit64/JitAsm.cpp b/Source/Core/Core/PowerPC/Jit64/JitAsm.cpp index eea2e75b0c3..05d08f767ee 100644 --- a/Source/Core/Core/PowerPC/Jit64/JitAsm.cpp +++ b/Source/Core/Core/PowerPC/Jit64/JitAsm.cpp @@ -4,9 +4,9 @@ #include "Core/PowerPC/Jit64/JitAsm.h" #include +#include #include "Common/CommonTypes.h" -#include "Common/EnumUtils.h" #include "Common/JitRegister.h" #include "Common/x64ABI.h" #include "Common/x64Emitter.h" @@ -99,7 +99,7 @@ void Jit64AsmRoutineManager::Generate() if (enable_debugging) { MOV(64, R(RSCRATCH), ImmPtr(system.GetCPU().GetStatePtr())); - CMP(32, MatR(RSCRATCH), Imm32(Common::ToUnderlying(CPU::State::Running))); + CMP(32, MatR(RSCRATCH), Imm32(std::to_underlying(CPU::State::Running))); dbg_exit = J_CC(CC_NE, Jump::Near); } @@ -230,7 +230,7 @@ void Jit64AsmRoutineManager::Generate() // Check the state pointer to see if we are exiting // Gets checked on at the end of every slice MOV(64, R(RSCRATCH), ImmPtr(system.GetCPU().GetStatePtr())); - CMP(32, MatR(RSCRATCH), Imm32(Common::ToUnderlying(CPU::State::Running))); + CMP(32, MatR(RSCRATCH), Imm32(std::to_underlying(CPU::State::Running))); J_CC(CC_E, outerLoop); // Landing pad for drec space diff --git a/Source/Core/Core/PowerPC/Jit64/RegCache/JitRegCache.cpp b/Source/Core/Core/PowerPC/Jit64/RegCache/JitRegCache.cpp index 2a787f31207..d1ebf9a0fda 100644 --- a/Source/Core/Core/PowerPC/Jit64/RegCache/JitRegCache.cpp +++ b/Source/Core/Core/PowerPC/Jit64/RegCache/JitRegCache.cpp @@ -12,7 +12,6 @@ #include "Common/Assert.h" #include "Common/BitSet.h" #include "Common/CommonTypes.h" -#include "Common/EnumUtils.h" #include "Common/MsgHandler.h" #include "Common/VariantUtil.h" #include "Common/x64Emitter.h" @@ -366,7 +365,7 @@ void RegCache::Discard(BitSet32 pregs) for (preg_t i : pregs) { ASSERT_MSG(DYNA_REC, !m_regs[i].IsLocked(), "Someone forgot to unlock PPC reg {} (X64 reg {}).", - i, Common::ToUnderlying(RX(i))); + i, std::to_underlying(RX(i))); ASSERT_MSG(DYNA_REC, !m_regs[i].IsRevertable(), "Register transaction is in progress for {}!", i); @@ -382,7 +381,7 @@ void RegCache::Flush(BitSet32 pregs, IgnoreDiscardedRegisters ignore_discarded_r for (preg_t i : pregs) { ASSERT_MSG(DYNA_REC, !m_regs[i].IsLocked(), "Someone forgot to unlock PPC reg {} (X64 reg {}).", - i, Common::ToUnderlying(RX(i))); + i, std::to_underlying(RX(i))); ASSERT_MSG(DYNA_REC, !m_regs[i].IsRevertable(), "Register transaction is in progress for {}!", i); @@ -451,7 +450,7 @@ BitSet32 RegCache::RegistersInUse() const void RegCache::FlushX(X64Reg reg) { ASSERT_MSG(DYNA_REC, reg < m_xregs.size(), "Flushing non-existent reg {}", - Common::ToUnderlying(reg)); + std::to_underlying(reg)); ASSERT(!m_xregs[reg].IsLocked()); if (!m_xregs[reg].IsFree()) { @@ -489,7 +488,7 @@ void RegCache::BindToRegister(preg_t i, bool doLoad, bool makeDirty) [xr](const auto& r) { return r.IsInHostRegister() && r.GetHostRegister() == xr; }), - "Xreg {} already bound", Common::ToUnderlying(xr)); + "Xreg {} already bound", std::to_underlying(xr)); m_regs[i].SetInHostRegister(xr, makeDirty); } @@ -505,7 +504,7 @@ void RegCache::BindToRegister(preg_t i, bool doLoad, bool makeDirty) DiscardImm(i); ASSERT_MSG(DYNA_REC, !m_xregs[RX(i)].IsLocked(), - "WTF, this reg ({} -> {}) should have been flushed", i, Common::ToUnderlying(RX(i))); + "WTF, this reg ({} -> {}) should have been flushed", i, std::to_underlying(RX(i))); } void RegCache::StoreFromRegister(preg_t i, FlushMode mode, diff --git a/Source/Core/Core/PowerPC/Jit64Common/Jit64AsmCommon.cpp b/Source/Core/Core/PowerPC/Jit64Common/Jit64AsmCommon.cpp index a08aaad0f4b..85942f19511 100644 --- a/Source/Core/Core/PowerPC/Jit64Common/Jit64AsmCommon.cpp +++ b/Source/Core/Core/PowerPC/Jit64Common/Jit64AsmCommon.cpp @@ -4,10 +4,10 @@ #include "Core/PowerPC/Jit64Common/Jit64AsmCommon.h" #include +#include #include "Common/CPUDetect.h" #include "Common/CommonTypes.h" -#include "Common/EnumUtils.h" #include "Common/FloatUtils.h" #include "Common/Intrinsics.h" #include "Common/JitRegister.h" @@ -368,7 +368,7 @@ const u8* CommonAsmRoutines::GenQuantizedStoreRuntime(bool single, EQuantizeType GenQuantizedStore(single, type, -1); RET(); Common::JitRegister::Register(start, GetCodePtr(), "JIT_QuantizedStore_{}_{}", - Common::ToUnderlying(type), single); + std::to_underlying(type), single); return load; } @@ -400,7 +400,7 @@ const u8* CommonAsmRoutines::GenQuantizedLoadRuntime(bool single, EQuantizeType GenQuantizedLoad(single, type, -1); RET(); Common::JitRegister::Register(start, GetCodePtr(), "JIT_QuantizedLoad_{}_{}", - Common::ToUnderlying(type), single); + std::to_underlying(type), single); return load; } diff --git a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp index 37bfc4c24ac..e5a19758d15 100644 --- a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp @@ -7,13 +7,13 @@ #include #include #include +#include #include #include #include "Common/Arm64Emitter.h" #include "Common/CommonTypes.h" -#include "Common/EnumUtils.h" #include "Common/GekkoDisassembler.h" #include "Common/HostDisassembler.h" #include "Common/Logging/Log.h" @@ -1297,7 +1297,7 @@ bool JitArm64::DoJit(u32 em_address, JitBlock* b, u32 nextPC) LDR(IndexType::Unsigned, ARM64Reg::W0, ARM64Reg::X0, MOVPage2R(ARM64Reg::X0, cpu.GetStatePtr())); - static_assert(Common::ToUnderlying(CPU::State::Running) == 0); + static_assert(std::to_underlying(CPU::State::Running) == 0); FixupBranch no_breakpoint = CBZ(ARM64Reg::W0); Cleanup(); diff --git a/Source/Core/Core/PowerPC/JitArm64/JitAsm.cpp b/Source/Core/Core/PowerPC/JitArm64/JitAsm.cpp index 56c26739a39..89ed9a2b053 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitAsm.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitAsm.cpp @@ -5,11 +5,11 @@ #include #include +#include #include "Common/Arm64Emitter.h" #include "Common/CommonTypes.h" #include "Common/Config/Config.h" -#include "Common/EnumUtils.h" #include "Common/FloatUtils.h" #include "Common/JitRegister.h" #include "Common/MathUtil.h" @@ -89,7 +89,7 @@ void JitArm64::GenerateAsm() { LDR(IndexType::Unsigned, ARM64Reg::W8, ARM64Reg::X8, MOVPage2R(ARM64Reg::X8, cpu.GetStatePtr())); - static_assert(Common::ToUnderlying(CPU::State::Running) == 0); + static_assert(std::to_underlying(CPU::State::Running) == 0); debug_exit = CBNZ(ARM64Reg::W8); } @@ -197,7 +197,7 @@ void JitArm64::GenerateAsm() // Check the state pointer to see if we are exiting // Gets checked on at the end of every slice LDR(IndexType::Unsigned, ARM64Reg::W8, ARM64Reg::X8, MOVPage2R(ARM64Reg::X8, cpu.GetStatePtr())); - static_assert(Common::ToUnderlying(CPU::State::Running) == 0); + static_assert(std::to_underlying(CPU::State::Running) == 0); FixupBranch exit = CBNZ(ARM64Reg::W8); SetJumpTarget(to_start_of_timing_slice); diff --git a/Source/Core/Core/WiiUtils.cpp b/Source/Core/Core/WiiUtils.cpp index 3dc6aa9f438..3ac5e222cfe 100644 --- a/Source/Core/Core/WiiUtils.cpp +++ b/Source/Core/Core/WiiUtils.cpp @@ -22,7 +22,6 @@ #include "Common/Assert.h" #include "Common/CommonTypes.h" #include "Common/Contains.h" -#include "Common/EnumUtils.h" #include "Common/FileUtil.h" #include "Common/HttpRequest.h" #include "Common/Logging/Log.h" @@ -80,7 +79,7 @@ static bool ImportWAD(IOS::HLE::Kernel& ios, const DiscIO::VolumeWAD& wad, if (ret != IOS::HLE::IOSC_FAIL_CHECKVALUE) { PanicAlertFmtT("WAD installation failed: Could not initialise title import (error {0}).", - Common::ToUnderlying(ret)); + std::to_underlying(ret)); } return false; } @@ -546,7 +545,7 @@ UpdateResult OnlineSystemUpdater::InstallTitleFromNUS(const std::string& prefix_ auto& es = m_ios.GetESCore(); if ((ret = es.ImportTicket(ticket.first, ticket.second)) < 0) { - ERROR_LOG_FMT(CORE, "Failed to import ticket: error {}", Common::ToUnderlying(ret)); + ERROR_LOG_FMT(CORE, "Failed to import ticket: error {}", std::to_underlying(ret)); return UpdateResult::ImportFailed; } @@ -578,7 +577,7 @@ UpdateResult OnlineSystemUpdater::InstallTitleFromNUS(const std::string& prefix_ IOS::HLE::ESCore::Context context; if ((ret = es.ImportTitleInit(context, tmd.first.GetBytes(), tmd.second)) < 0) { - ERROR_LOG_FMT(CORE, "Failed to initialise title import: error {}", Common::ToUnderlying(ret)); + ERROR_LOG_FMT(CORE, "Failed to initialise title import: error {}", std::to_underlying(ret)); return UpdateResult::ImportFailed; } @@ -597,7 +596,7 @@ UpdateResult OnlineSystemUpdater::InstallTitleFromNUS(const std::string& prefix_ if ((ret = es.ImportContentBegin(context, title.id, content.id)) < 0) { ERROR_LOG_FMT(CORE, "Failed to initialise import for content {:08x}: error {}", content.id, - Common::ToUnderlying(ret)); + std::to_underlying(ret)); return UpdateResult::ImportFailed; } @@ -622,7 +621,7 @@ UpdateResult OnlineSystemUpdater::InstallTitleFromNUS(const std::string& prefix_ if ((all_contents_imported && (ret = es.ImportTitleDone(context)) < 0) || (!all_contents_imported && (ret = es.ImportTitleCancel(context)) < 0)) { - ERROR_LOG_FMT(CORE, "Failed to finalise title import: error {}", Common::ToUnderlying(ret)); + ERROR_LOG_FMT(CORE, "Failed to finalise title import: error {}", std::to_underlying(ret)); return UpdateResult::ImportFailed; } diff --git a/Source/Core/DolphinLib.props b/Source/Core/DolphinLib.props index 128e875ae3b..2ad92b44e6f 100644 --- a/Source/Core/DolphinLib.props +++ b/Source/Core/DolphinLib.props @@ -56,7 +56,6 @@ - diff --git a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp index 0aa77d53110..57a7eb634f6 100644 --- a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp @@ -3,6 +3,8 @@ #include "DolphinQt/Config/Graphics/EnhancementsWidget.h" +#include + #include #include #include @@ -10,7 +12,6 @@ #include #include "Common/CommonTypes.h" -#include "Common/EnumUtils.h" #include "Core/Config/GraphicsSettings.h" @@ -47,14 +48,14 @@ EnhancementsWidget::EnhancementsWidget(GraphicsPane* gfx_pane) }); } -constexpr int ANISO_1x = Common::ToUnderlying(AnisotropicFilteringMode::Force1x); -constexpr int ANISO_2X = Common::ToUnderlying(AnisotropicFilteringMode::Force2x); -constexpr int ANISO_4X = Common::ToUnderlying(AnisotropicFilteringMode::Force4x); -constexpr int ANISO_8X = Common::ToUnderlying(AnisotropicFilteringMode::Force8x); -constexpr int ANISO_16X = Common::ToUnderlying(AnisotropicFilteringMode::Force16x); -constexpr int FILTERING_DEFAULT = Common::ToUnderlying(TextureFilteringMode::Default); -constexpr int FILTERING_NEAREST = Common::ToUnderlying(TextureFilteringMode::Nearest); -constexpr int FILTERING_LINEAR = Common::ToUnderlying(TextureFilteringMode::Linear); +constexpr int ANISO_1x = std::to_underlying(AnisotropicFilteringMode::Force1x); +constexpr int ANISO_2X = std::to_underlying(AnisotropicFilteringMode::Force2x); +constexpr int ANISO_4X = std::to_underlying(AnisotropicFilteringMode::Force4x); +constexpr int ANISO_8X = std::to_underlying(AnisotropicFilteringMode::Force8x); +constexpr int ANISO_16X = std::to_underlying(AnisotropicFilteringMode::Force16x); +constexpr int FILTERING_DEFAULT = std::to_underlying(TextureFilteringMode::Default); +constexpr int FILTERING_NEAREST = std::to_underlying(TextureFilteringMode::Nearest); +constexpr int FILTERING_LINEAR = std::to_underlying(TextureFilteringMode::Linear); void EnhancementsWidget::CreateWidgets() { diff --git a/Source/Core/DolphinQt/Config/SettingsWindow.cpp b/Source/Core/DolphinQt/Config/SettingsWindow.cpp index 947edb39181..2898b4cd8ae 100644 --- a/Source/Core/DolphinQt/Config/SettingsWindow.cpp +++ b/Source/Core/DolphinQt/Config/SettingsWindow.cpp @@ -3,6 +3,8 @@ #include "DolphinQt/Config/SettingsWindow.h" +#include + #include #include #include @@ -14,8 +16,6 @@ #include #include -#include "Common/EnumUtils.h" - #include "DolphinQt/Config/ControllersPane.h" #include "DolphinQt/Config/Graphics/GraphicsPane.h" #include "DolphinQt/MainWindow.h" @@ -206,5 +206,5 @@ SettingsWindow::SettingsWindow(MainWindow* parent) : StackedSettingsWindow{paren void SettingsWindow::SelectPane(SettingsWindowPaneIndex index) { - ActivatePane(Common::ToUnderlying(index)); + ActivatePane(std::to_underlying(index)); } diff --git a/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp b/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp index ae06a30dfc7..5a8b216b0c2 100644 --- a/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp +++ b/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -20,7 +21,6 @@ #include #include "Common/Assert.h" -#include "Common/EnumUtils.h" #include "Common/Swap.h" #include "Core/FifoPlayer/FifoPlayer.h" @@ -264,7 +264,7 @@ public: const u32 object_prim_size = num_vertices * vertex_size; const u8 opcode = - 0x80 | Common::ToUnderlying(primitive) << OpcodeDecoder::GX_PRIMITIVE_SHIFT | vat; + 0x80 | std::to_underlying(primitive) << OpcodeDecoder::GX_PRIMITIVE_SHIFT | vat; text = QStringLiteral("PRIMITIVE %1 (%2) %3 vertices %4 bytes/vertex %5 total bytes") .arg(QString::fromStdString(name)) .arg(opcode, 2, 16, QLatin1Char('0')) diff --git a/Source/Core/VideoBackends/Vulkan/VKGfx.cpp b/Source/Core/VideoBackends/Vulkan/VKGfx.cpp index c071d99357a..c88e422c982 100644 --- a/Source/Core/VideoBackends/Vulkan/VKGfx.cpp +++ b/Source/Core/VideoBackends/Vulkan/VKGfx.cpp @@ -5,9 +5,9 @@ #include #include +#include #include "Common/CommonTypes.h" -#include "Common/EnumUtils.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" @@ -273,7 +273,7 @@ bool VKGfx::BindBackbuffer(const ClearColor& clear_color) else { ERROR_LOG_FMT(VIDEO, "Unknown present error {:#010X} {}, please report.", - Common::ToUnderlying(res), VkResultToString(res)); + std::to_underlying(res), VkResultToString(res)); m_swap_chain->RecreateSwapChain(); } @@ -286,8 +286,8 @@ bool VKGfx::BindBackbuffer(const ClearColor& clear_color) } else { - PanicAlertFmt("Failed to grab image from swap chain: {:#010X} {}", - Common::ToUnderlying(res), VkResultToString(res)); + PanicAlertFmt("Failed to grab image from swap chain: {:#010X} {}", std::to_underlying(res), + VkResultToString(res)); } } } diff --git a/Source/Core/VideoCommon/CPMemory.cpp b/Source/Core/VideoCommon/CPMemory.cpp index 9b47a13da01..2efb000d90a 100644 --- a/Source/Core/VideoCommon/CPMemory.cpp +++ b/Source/Core/VideoCommon/CPMemory.cpp @@ -5,9 +5,9 @@ #include #include +#include #include "Common/ChunkFile.h" -#include "Common/EnumUtils.h" #include "Common/Logging/Log.h" #include "Core/DolphinAnalytics.h" #include "Core/System.h" @@ -112,7 +112,7 @@ void CPState::LoadCPReg(u8 sub_cmd, u32 value) WARN_LOG_FMT(VIDEO, "CP MATINDEX_A: an exact value of {:02x} was expected " "but instead a value of {:02x} was seen", - Common::ToUnderlying(MATINDEX_A), sub_cmd); + std::to_underlying(MATINDEX_A), sub_cmd); } matrix_index_a.Hex = value; @@ -125,7 +125,7 @@ void CPState::LoadCPReg(u8 sub_cmd, u32 value) WARN_LOG_FMT(VIDEO, "CP MATINDEX_B: an exact value of {:02x} was expected " "but instead a value of {:02x} was seen", - Common::ToUnderlying(MATINDEX_B), sub_cmd); + std::to_underlying(MATINDEX_B), sub_cmd); } matrix_index_b.Hex = value; @@ -138,7 +138,7 @@ void CPState::LoadCPReg(u8 sub_cmd, u32 value) WARN_LOG_FMT(VIDEO, "CP VCD_LO: an exact value of {:02x} was expected " "but instead a value of {:02x} was seen", - Common::ToUnderlying(VCD_LO), sub_cmd); + std::to_underlying(VCD_LO), sub_cmd); } vtx_desc.low.Hex = value; @@ -151,7 +151,7 @@ void CPState::LoadCPReg(u8 sub_cmd, u32 value) WARN_LOG_FMT(VIDEO, "CP VCD_HI: an exact value of {:02x} was expected " "but instead a value of {:02x} was seen", - Common::ToUnderlying(VCD_HI), sub_cmd); + std::to_underlying(VCD_HI), sub_cmd); } vtx_desc.high.Hex = value; diff --git a/Source/Core/VideoCommon/Resources/MaterialResource.cpp b/Source/Core/VideoCommon/Resources/MaterialResource.cpp index 657647ffb98..38486d79322 100644 --- a/Source/Core/VideoCommon/Resources/MaterialResource.cpp +++ b/Source/Core/VideoCommon/Resources/MaterialResource.cpp @@ -3,6 +3,8 @@ #include "VideoCommon/Resources/MaterialResource.h" +#include + #include #include "Common/VariantUtil.h" @@ -30,7 +32,7 @@ SamplerState CalculateSamplerAnisotropy(const SamplerState& initial_sampler) if (g_ActiveConfig.iMaxAnisotropy != AnisotropicFilteringMode::Default && IsAnisotropicEnhancementSafe(state.tm0)) { - state.tm0.anisotropic_filtering = Common::ToUnderlying(g_ActiveConfig.iMaxAnisotropy); + state.tm0.anisotropic_filtering = std::to_underlying(g_ActiveConfig.iMaxAnisotropy); } if (state.tm0.anisotropic_filtering != 0) diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 6ae8b4f96f7..2b1fab27b54 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -21,7 +21,6 @@ #include "Common/Assert.h" #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" -#include "Common/EnumUtils.h" #include "Common/FileUtil.h" #include "Common/Hash.h" #include "Common/Logging/Log.h" @@ -1031,7 +1030,7 @@ SamplerState TextureCacheBase::GetSamplerState(u32 index, float custom_tex_scale if (g_ActiveConfig.iMaxAnisotropy != AnisotropicFilteringMode::Default && IsAnisotropicEnhancementSafe(tm0)) { - state.tm0.anisotropic_filtering = Common::ToUnderlying(g_ActiveConfig.iMaxAnisotropy); + state.tm0.anisotropic_filtering = std::to_underlying(g_ActiveConfig.iMaxAnisotropy); } if (state.tm0.anisotropic_filtering != 0) diff --git a/Source/Core/VideoCommon/UberShaderCommon.cpp b/Source/Core/VideoCommon/UberShaderCommon.cpp index d35f2037376..f605081481d 100644 --- a/Source/Core/VideoCommon/UberShaderCommon.cpp +++ b/Source/Core/VideoCommon/UberShaderCommon.cpp @@ -3,7 +3,8 @@ #include "VideoCommon/UberShaderCommon.h" -#include "Common/EnumUtils.h" +#include + #include "VideoCommon/NativeVertexFormat.h" #include "VideoCommon/ShaderGenCommon.h" #include "VideoCommon/VideoCommon.h" @@ -120,11 +121,11 @@ void WriteVertexLighting(ShaderCode& out, APIType api_type, std::string_view wor out.Write(" if ({} != 0u) {{\n", BitfieldExtract<&LitChannel::enablelighting>("alphareg")); out.Write(" if ({} != 0u) {{\n", BitfieldExtract<&LitChannel::ambsource>("alphareg")); out.Write(" if ((components & ({}u << chan)) != 0u) // VB_HAS_COL0\n", - Common::ToUnderlying(VB_HAS_COL0)); + std::to_underlying(VB_HAS_COL0)); out.Write(" lacc.w = int(round(((chan == 0u) ? {}.w : {}.w) * 255.0));\n", in_color_0_var, in_color_1_var); out.Write(" else if ((components & {}u) != 0u) // VB_HAS_COLO0\n", - Common::ToUnderlying(VB_HAS_COL0)); + std::to_underlying(VB_HAS_COL0)); out.Write(" lacc.w = int(round({}.w * 255.0));\n", in_color_0_var); out.Write(" else\n" " lacc.w = 255;\n" diff --git a/Source/Core/VideoCommon/UberShaderVertex.cpp b/Source/Core/VideoCommon/UberShaderVertex.cpp index a6c0502dfec..e558637d97f 100644 --- a/Source/Core/VideoCommon/UberShaderVertex.cpp +++ b/Source/Core/VideoCommon/UberShaderVertex.cpp @@ -3,7 +3,8 @@ #include "VideoCommon/UberShaderVertex.h" -#include "Common/EnumUtils.h" +#include + #include "VideoCommon/ConstantManager.h" #include "VideoCommon/DriverDetails.h" #include "VideoCommon/NativeVertexFormat.h" @@ -224,7 +225,7 @@ float3 load_input_float3_rawtex(uint vtx_offset, uint attr_offset) {{ "float3 N2;\n" "\n" "if ((components & {}u) != 0u) {{ // VB_HAS_POSMTXIDX\n", - Common::ToUnderlying(VB_HAS_POSMTXIDX)); + std::to_underlying(VB_HAS_POSMTXIDX)); LoadVertexAttribute(out, host_config, 2, "posmtx", "uint4", "ubyte4"); out.Write(" // Vertex format has a per-vertex matrix\n" " int posidx = int(posmtx.r);\n" @@ -256,7 +257,7 @@ float3 load_input_float3_rawtex(uint vtx_offset, uint attr_offset) {{ "float3 _rawbinormal;\n" "if ((components & {}u) != 0u) // VB_HAS_NORMAL\n" "{{\n", - Common::ToUnderlying(VB_HAS_NORMAL)); + std::to_underlying(VB_HAS_NORMAL)); LoadVertexAttribute(out, host_config, 2, "rawnormal", "float3", "float3"); out.Write(" _rawnormal = rawnormal;\n" "}}\n" @@ -267,7 +268,7 @@ float3 load_input_float3_rawtex(uint vtx_offset, uint attr_offset) {{ "\n" "if ((components & {}u) != 0u) // VB_HAS_TANGENT\n" "{{\n", - Common::ToUnderlying(VB_HAS_TANGENT)); + std::to_underlying(VB_HAS_TANGENT)); LoadVertexAttribute(out, host_config, 2, "rawtangent", "float3", "float3"); out.Write(" _rawtangent = rawtangent;\n" "}}\n" @@ -278,7 +279,7 @@ float3 load_input_float3_rawtex(uint vtx_offset, uint attr_offset) {{ "\n" "if ((components & {}u) != 0u) // VB_HAS_BINORMAL\n" "{{\n", - Common::ToUnderlying(VB_HAS_BINORMAL)); + std::to_underlying(VB_HAS_BINORMAL)); LoadVertexAttribute(out, host_config, 2, "rawbinormal", "float3", "float3"); out.Write(" _rawbinormal = rawbinormal;\n" "}}\n" @@ -320,14 +321,14 @@ float3 load_input_float3_rawtex(uint vtx_offset, uint attr_offset) {{ "}}\n" "else if ((components & {}u) != 0u) // VB_HAS_COL0\n" "{{\n", - Common::ToUnderlying(VB_HAS_COL0)); + std::to_underlying(VB_HAS_COL0)); LoadVertexAttribute(out, host_config, 2, "rawcolor0", "float4", "ubyte4"); out.Write(" vertex_color_0 = rawcolor0;\n" " vertex_color_1 = rawcolor0;\n" "}}\n" "else if ((components & {}u) != 0u) // VB_HAS_COL1\n" "{{\n", - Common::ToUnderlying(VB_HAS_COL1)); + std::to_underlying(VB_HAS_COL1)); LoadVertexAttribute(out, host_config, 2, "rawcolor1", "float4", "ubyte4"); out.Write(" vertex_color_0 = rawcolor1;\n" " vertex_color_1 = rawcolor1;\n" @@ -347,7 +348,7 @@ float3 load_input_float3_rawtex(uint vtx_offset, uint attr_offset) {{ if (host_config.backend_vs_point_line_expand) { - out.Write("if (vs_expand == {}u) {{ // Line\n", Common::ToUnderlying(VSExpand::Line)); + out.Write("if (vs_expand == {}u) {{ // Line\n", std::to_underlying(VSExpand::Line)); out.Write(" bool is_bottom = (gl_VertexID & 2) != 0;\n" " bool is_right = (gl_VertexID & 1) != 0;\n" " uint other_base_offset = vertex_base_offset;\n" @@ -362,7 +363,7 @@ float3 load_input_float3_rawtex(uint vtx_offset, uint attr_offset) {{ " float4 other_p1 = P1;\n" " float4 other_p2 = P2;\n" " if ((components & {}u) != 0u) {{ // VB_HAS_POSMTXIDX\n", - Common::ToUnderlying(VB_HAS_POSMTXIDX)); + std::to_underlying(VB_HAS_POSMTXIDX)); out.Write(" uint other_posidx = load_input_uint4_ubyte4(other_base_offset, " "vertex_offset_posmtx).r;\n" " other_p0 = " I_TRANSFORMMATRICES "[other_posidx];\n" @@ -372,7 +373,7 @@ float3 load_input_float3_rawtex(uint vtx_offset, uint attr_offset) {{ " float4 other_pos = float4(dot(other_p0, other_rawpos), " "dot(other_p1, other_rawpos), dot(other_p2, other_rawpos), 1.0);\n"); GenerateVSLineExpansion(out, " ", num_texgen); - out.Write("}} else if (vs_expand == {}u) {{ // Point\n", Common::ToUnderlying(VSExpand::Point)); + out.Write("}} else if (vs_expand == {}u) {{ // Point\n", std::to_underlying(VSExpand::Point)); out.Write(" bool is_bottom = (gl_VertexID & 2) != 0;\n" " bool is_right = (gl_VertexID & 1) != 0;\n"); GenerateVSPointExpansion(out, " ", num_texgen); @@ -552,7 +553,7 @@ static void GenVertexShaderTexGens(APIType api_type, const ShaderHostConfig& hos out.Write(" case {:s}:\n", SourceRow::Normal); out.Write(" if ((components & {}u) != 0u) // VB_HAS_NORMAL\n" " {{\n", - Common::ToUnderlying(VB_HAS_NORMAL)); + std::to_underlying(VB_HAS_NORMAL)); LoadVertexAttribute(out, host_config, 6, "rawnormal", "float3", "float3"); out.Write(" coord.xyz = rawnormal.xyz;\n" " }}\n" @@ -560,7 +561,7 @@ static void GenVertexShaderTexGens(APIType api_type, const ShaderHostConfig& hos out.Write(" case {:s}:\n", SourceRow::BinormalT); out.Write(" if ((components & {}u) != 0u) // VB_HAS_TANGENT\n" " {{\n", - Common::ToUnderlying(VB_HAS_TANGENT)); + std::to_underlying(VB_HAS_TANGENT)); LoadVertexAttribute(out, host_config, 6, "rawtangent", "float3", "float3"); out.Write(" coord.xyz = rawtangent.xyz;\n" " }}\n" @@ -568,14 +569,14 @@ static void GenVertexShaderTexGens(APIType api_type, const ShaderHostConfig& hos out.Write(" case {:s}:\n", SourceRow::BinormalB); out.Write(" if ((components & {}u) != 0u) // VB_HAS_BINORMAL\n" " {{\n", - Common::ToUnderlying(VB_HAS_BINORMAL)); + std::to_underlying(VB_HAS_BINORMAL)); LoadVertexAttribute(out, host_config, 6, "rawbinormal", "float3", "float3"); out.Write(" coord.xyz = rawbinormal.xyz;\n" " }}\n" " break;\n\n"); for (u32 i = 0; i < 8; i++) { - out.Write(" case {:s}:\n", static_cast(Common::ToUnderlying(SourceRow::Tex0) + i)); + out.Write(" case {:s}:\n", static_cast(std::to_underlying(SourceRow::Tex0) + i)); out.Write(" if ((components & {}u) != 0u) // VB_HAS_UV{}\n" " {{\n", VB_HAS_UV0 << i, i); @@ -632,7 +633,7 @@ static void GenVertexShaderTexGens(APIType api_type, const ShaderHostConfig& hos out.Write(" default:\n" " {{\n"); out.Write(" if ((components & ({}u /* VB_HAS_TEXMTXIDX0 */ << texgen)) != 0u) {{\n", - Common::ToUnderlying(VB_HAS_TEXMTXIDX0)); + std::to_underlying(VB_HAS_TEXMTXIDX0)); if (host_config.backend_dynamic_vertex_loader || host_config.backend_vs_point_line_expand) { out.Write(" int tmp = int(load_input_float3_rawtex(vertex_base_offset, "