summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-01-14 23:23:37 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2021-01-18 15:51:18 +0100
commit2d8757f879d8f410319aae41ff902ba5a679d9dd (patch)
tree4ef80a0f475f6aeff3a7ae4b2c1ead34dc838a82 /src
parentec12c302493e69deb9b3019ecb182068518691ac (diff)
QVariant::fromValue<T>: require T to be copy constructible
In Qt 5, QVariant::fromValue<T> would not compile unless Q_DECLARE_METATYPE(T) was used, and Q_DECLARE_METATYPE(T) would lead to a compile error if T were not copy constructible. In Qt 6, we do not require Q_DECLARE_METATYPE before using fromValue, and QMetaType itself works with non-copy constructible types just fine. However, QVariant still requires it, thus we need to now enforce this in fromValue itself. Change-Id: Ib6964a438d8c46033dd3a037b9d871de2b42e175 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qvariant.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index 8c3a27e3ca..b7d347a61e 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -392,7 +392,12 @@ class Q_CORE_EXPORT QVariant
}
template<typename T>
+#ifndef Q_CLANG_QDOC
+ static inline auto fromValue(const T &value) ->
+ std::enable_if_t<std::is_copy_constructible_v<T>, QVariant>
+#else
static inline QVariant fromValue(const T &value)
+#endif
{
return QVariant(QMetaType::fromType<T>(), std::addressof(value));
}