mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-01 13:18:06 -06: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:
@@ -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.");
|
||||
|
||||
@@ -55,9 +55,9 @@ namespace Utils
|
||||
|
||||
constexpr Version() = default;
|
||||
|
||||
template <typename ... Ts
|
||||
, typename std::enable_if_t<std::conjunction_v<std::is_convertible<Ts, int>...>, int> = 0>
|
||||
template <typename ... Ts>
|
||||
constexpr Version(Ts ... params)
|
||||
requires std::conjunction_v<std::is_convertible<Ts, int>...>
|
||||
: m_components {{params ...}}
|
||||
{
|
||||
static_assert((sizeof...(Ts) <= N), "Too many parameters provided");
|
||||
|
||||
Reference in New Issue
Block a user