QVariant: replace fromValue() specializations with if-constexpr
Keeps all the special cases in a central place and will help with adding an rvalue overload of fromValue() for 6.6. Change-Id: I14f12bb98a2e2f4edfcec8ce39660643e23c1d07 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>bb10
parent
114d00f043
commit
f9fe333018
|
|
@ -563,6 +563,10 @@ public:
|
|||
{
|
||||
if constexpr (std::is_null_pointer_v<T>)
|
||||
return QVariant(QMetaType::fromType<std::nullptr_t>());
|
||||
else if constexpr (std::is_same_v<T, QVariant>)
|
||||
return value;
|
||||
else if constexpr (std::is_same_v<T, std::monostate>)
|
||||
return QVariant();
|
||||
return QVariant(QMetaType::fromType<T>(), std::addressof(value));
|
||||
}
|
||||
|
||||
|
|
@ -693,18 +697,6 @@ public:
|
|||
inline const DataPtr &data_ptr() const { return d; }
|
||||
};
|
||||
|
||||
template<>
|
||||
inline QVariant QVariant::fromValue(const QVariant &value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline QVariant QVariant::fromValue(const std::monostate &) noexcept
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
inline bool QVariant::isValid() const
|
||||
{
|
||||
return d.type().isValid();
|
||||
|
|
|
|||
Loading…
Reference in New Issue