From 2dc975fa923cfabcd0ee4459eb608219a72e4e02 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Mon, 5 May 2025 19:30:53 -0500 Subject: Common: Replace enable_if with concepts and other minor modernizations. --- Source/Core/Common/Config/ConfigInfo.h | 15 +++------------ Source/Core/Common/Config/Layer.h | 5 +++-- 2 files changed, 6 insertions(+), 14 deletions(-) (limited to 'Source/Core/Common/Config') diff --git a/Source/Core/Common/Config/ConfigInfo.h b/Source/Core/Common/Config/ConfigInfo.h index be3d00108b..e8d904fae2 100644 --- a/Source/Core/Common/Config/ConfigInfo.h +++ b/Source/Core/Common/Config/ConfigInfo.h @@ -6,21 +6,14 @@ #include #include #include -#include #include #include "Common/CommonTypes.h" #include "Common/Config/Enums.h" +#include "Common/TypeUtils.h" namespace Config { -namespace detail -{ -// std::underlying_type may only be used with enum types, so make sure T is an enum type first. -template -using UnderlyingType = typename std::enable_if_t{}, std::underlying_type>::type; -} // namespace detail - struct Location { System system{}; @@ -54,8 +47,7 @@ public: // Make it easy to convert Info into Info> // so that enum settings can still easily work with code that doesn't care about the enum values. - template >::value>* = nullptr> + template Enum> Info(const Info& other) { *this = other; @@ -80,8 +72,7 @@ public: // Make it easy to convert Info into Info> // so that enum settings can still easily work with code that doesn't care about the enum values. - template >::value>* = nullptr> + template Enum> Info& operator=(const Info& other) { m_location = other.GetLocation(); diff --git a/Source/Core/Common/Config/Layer.h b/Source/Core/Common/Config/Layer.h index e82b411c29..3234cc0638 100644 --- a/Source/Core/Common/Config/Layer.h +++ b/Source/Core/Common/Config/Layer.h @@ -23,7 +23,8 @@ struct DefaultState namespace detail { -template ::value>* = nullptr> +template +requires(!Common::Enum) std::optional TryParse(const std::string& str_value) { T value; @@ -32,7 +33,7 @@ std::optional TryParse(const std::string& str_value) return value; } -template ::value>* = nullptr> +template std::optional TryParse(const std::string& str_value) { const auto result = TryParse>(str_value); -- cgit v1.2.3