From f9fe3330181db7eef7eb8469ca7371517153f66b Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Fri, 2 Jun 2023 13:33:07 +0200 Subject: 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 Reviewed-by: Fabian Kosmale --- src/corelib/kernel/qvariant.h | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index fe99ad6bdd..ed4978699f 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -563,6 +563,10 @@ public: { if constexpr (std::is_null_pointer_v) return QVariant(QMetaType::fromType()); + else if constexpr (std::is_same_v) + return value; + else if constexpr (std::is_same_v) + return QVariant(); return QVariant(QMetaType::fromType(), 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(); -- cgit v1.2.3