From c5ace605dd1090e99dd7a252ab1b14623b43b22c Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Thu, 3 Apr 2025 17:46:31 -0500 Subject: [PATCH] StringUtil: Use requires-clause instead of enable_if. --- Source/Core/Common/StringUtil.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Source/Core/Common/StringUtil.h b/Source/Core/Common/StringUtil.h index 8ccc05ee6b..2c97be9b6a 100644 --- a/Source/Core/Common/StringUtil.h +++ b/Source/Core/Common/StringUtil.h @@ -123,8 +123,8 @@ requires(detail::IsBooleanEnum()) bool TryParse(const std::string& str, T* ou return true; } -template >* = nullptr> -bool TryParse(std::string str, T* const output) +template +requires(std::is_floating_point_v) bool TryParse(std::string str, T* const output) { // Replace commas with dots. std::istringstream iss(ReplaceAll(std::move(str), ",", ".")); @@ -169,8 +169,8 @@ std::string ValueToString(double value); std::string ValueToString(int value); std::string ValueToString(s64 value); std::string ValueToString(bool value); -template ::value>* = nullptr> -std::string ValueToString(T value) +template +requires(std::is_enum_v) std::string ValueToString(T value) { return ValueToString(static_cast>(value)); } @@ -180,16 +180,17 @@ std::string HexDump(const u8* data, size_t size); namespace Common { -template >* = nullptr> -std::from_chars_result FromChars(std::string_view sv, T& value, int base = 10) +template +requires(std::is_integral_v) std::from_chars_result + FromChars(std::string_view sv, T& value, int base = 10) { const char* const first = sv.data(); const char* const last = first + sv.size(); return std::from_chars(first, last, value, base); } -template >* = nullptr> -std::from_chars_result FromChars(std::string_view sv, T& value, - std::chars_format fmt = std::chars_format::general) +template +requires(std::is_floating_point_v) std::from_chars_result + FromChars(std::string_view sv, T& value, std::chars_format fmt = std::chars_format::general) { const char* const first = sv.data(); const char* const last = first + sv.size();