summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Config
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2025-05-05 19:30:53 -0500
committerJordan Woyak <jordan.woyak@gmail.com>2025-05-05 19:34:24 -0500
commit2dc975fa923cfabcd0ee4459eb608219a72e4e02 (patch)
treeb11251616ef7581e5f5efdebf8587fff84f96e1d /Source/Core/Common/Config
parent210b5cbf66a8c1aa28cf95aff8985ea54138ef8b (diff)
Common: Replace enable_if with concepts and other minor modernizations.
Diffstat (limited to 'Source/Core/Common/Config')
-rw-r--r--Source/Core/Common/Config/ConfigInfo.h15
-rw-r--r--Source/Core/Common/Config/Layer.h5
2 files changed, 6 insertions, 14 deletions
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 <mutex>
#include <shared_mutex>
#include <string>
-#include <type_traits>
#include <utility>
#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 <typename T>
-using UnderlyingType = typename std::enable_if_t<std::is_enum<T>{}, std::underlying_type<T>>::type;
-} // namespace detail
-
struct Location
{
System system{};
@@ -54,8 +47,7 @@ public:
// Make it easy to convert Info<Enum> into Info<UnderlyingType<Enum>>
// so that enum settings can still easily work with code that doesn't care about the enum values.
- template <typename Enum,
- std::enable_if_t<std::is_same<T, detail::UnderlyingType<Enum>>::value>* = nullptr>
+ template <Common::TypedEnum<T> Enum>
Info(const Info<Enum>& other)
{
*this = other;
@@ -80,8 +72,7 @@ public:
// Make it easy to convert Info<Enum> into Info<UnderlyingType<Enum>>
// so that enum settings can still easily work with code that doesn't care about the enum values.
- template <typename Enum,
- std::enable_if_t<std::is_same<T, detail::UnderlyingType<Enum>>::value>* = nullptr>
+ template <Common::TypedEnum<T> Enum>
Info<T>& operator=(const Info<Enum>& 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 <typename T, std::enable_if_t<!std::is_enum<T>::value>* = nullptr>
+template <typename T>
+requires(!Common::Enum<T>)
std::optional<T> TryParse(const std::string& str_value)
{
T value;
@@ -32,7 +33,7 @@ std::optional<T> TryParse(const std::string& str_value)
return value;
}
-template <typename T, std::enable_if_t<std::is_enum<T>::value>* = nullptr>
+template <Common::Enum T>
std::optional<T> TryParse(const std::string& str_value)
{
const auto result = TryParse<std::underlying_type_t<T>>(str_value);