Merge pull request #14013 from jordan-woyak/hle-varargs-concepts

HLE_VarArgs: Replace enable_if with concepts.
This commit is contained in:
Admiral H. Curtiss 2025-10-15 21:14:05 +02:00 committed by GitHub
commit 952f2cae80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 10 deletions

View File

@ -6,6 +6,7 @@
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
#include "Core/Core.h" #include "Core/Core.h"
#include "Core/PowerPC/PowerPC.h"
#include "Core/System.h" #include "Core/System.h"
HLE::SystemVABI::VAList::~VAList() = default; HLE::SystemVABI::VAList::~VAList() = default;

View File

@ -9,7 +9,6 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Core/PowerPC/MMU.h" #include "Core/PowerPC/MMU.h"
#include "Core/PowerPC/PowerPC.h"
namespace Core namespace Core
{ {
@ -19,15 +18,14 @@ class System;
namespace HLE::SystemVABI namespace HLE::SystemVABI
{ {
// SFINAE
template <typename T> template <typename T>
constexpr bool IS_ARG_POINTER = std::is_union<T>() || std::is_class<T>(); concept ArgPointer = std::is_union_v<T> || std::is_class_v<T>;
template <typename T> template <typename T>
constexpr bool IS_WORD = std::is_pointer<T>() || (std::is_integral<T>() && sizeof(T) <= 4); concept ArgWord = std::is_pointer_v<T> || (std::is_integral_v<T> && sizeof(T) <= 4);
template <typename T> template <typename T>
constexpr bool IS_DOUBLE_WORD = std::is_integral<T>() && sizeof(T) == 8; concept ArgDoubleWord = std::is_integral_v<T> && sizeof(T) == 8;
template <typename T> template <typename T>
constexpr bool IS_ARG_REAL = std::is_floating_point<T>(); concept ArgReal = std::is_floating_point_v<T>;
// See System V ABI (SVR4) for more details // See System V ABI (SVR4) for more details
// -> 3-18 Parameter Passing // -> 3-18 Parameter Passing
@ -47,7 +45,7 @@ public:
virtual ~VAList(); virtual ~VAList();
// 0 - arg_ARGPOINTER // 0 - arg_ARGPOINTER
template <typename T, typename std::enable_if_t<IS_ARG_POINTER<T>>* = nullptr> template <ArgPointer T>
T GetArg() T GetArg()
{ {
T obj; T obj;
@ -62,7 +60,7 @@ public:
} }
// 1 - arg_WORD // 1 - arg_WORD
template <typename T, typename std::enable_if_t<IS_WORD<T>>* = nullptr> template <ArgWord T>
T GetArg() T GetArg()
{ {
static_assert(!std::is_pointer<T>(), "VAList doesn't support pointers"); static_assert(!std::is_pointer<T>(), "VAList doesn't support pointers");
@ -84,7 +82,7 @@ public:
} }
// 2 - arg_DOUBLEWORD // 2 - arg_DOUBLEWORD
template <typename T, typename std::enable_if_t<IS_DOUBLE_WORD<T>>* = nullptr> template <ArgDoubleWord T>
T GetArg() T GetArg()
{ {
u64 value; u64 value;
@ -107,7 +105,7 @@ public:
} }
// 3 - arg_ARGREAL // 3 - arg_ARGREAL
template <typename T, typename std::enable_if_t<IS_ARG_REAL<T>>* = nullptr> template <ArgReal T>
T GetArg() T GetArg()
{ {
double value; double value;