mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 12:59:56 -07:00
Replace template conditionals with C++20 requires
clause
Related: https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-constraints.html PR #19424.
This commit is contained in:
parent
33d767b765
commit
5c06d0aa75
6 changed files with 23 additions and 31 deletions
|
@ -67,8 +67,9 @@ namespace Utils::String
|
|||
|
||||
QString fromDouble(double n, int precision);
|
||||
|
||||
template <typename T, typename std::enable_if_t<std::is_enum_v<T>, int> = 0>
|
||||
template <typename T>
|
||||
QString fromEnum(const T &value)
|
||||
requires std::is_enum_v<T>
|
||||
{
|
||||
static_assert(std::is_same_v<int, typename std::underlying_type_t<T>>,
|
||||
"Enumeration underlying type has to be int.");
|
||||
|
@ -77,8 +78,9 @@ namespace Utils::String
|
|||
return QString::fromLatin1(metaEnum.valueToKey(static_cast<int>(value)));
|
||||
}
|
||||
|
||||
template <typename T, typename std::enable_if_t<std::is_enum_v<T>, int> = 0>
|
||||
template <typename T>
|
||||
T toEnum(const QString &serializedValue, const T &defaultValue)
|
||||
requires std::is_enum_v<T>
|
||||
{
|
||||
static_assert(std::is_same_v<int, typename std::underlying_type_t<T>>,
|
||||
"Enumeration underlying type has to be int.");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue