summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qvariant.h
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2022-07-25 09:37:19 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2022-07-27 23:51:17 +0200
commit708e4ea23561e28f4032a74eda7e74998087acf2 (patch)
treedd09d8fb62a0119531b8cd7ec3f79e2e36297eab /src/corelib/kernel/qvariant.h
parent2f0a625fd4036b71286dfa7de4c9d795025164e7 (diff)
QVariant: prepare removal of nullptr_t special casing in Qt 7
customConstruct has to do an additional check to ensure that QVariant::fromValue(nullptr) returns null. We can get rid of it by special casing nullptr_t in a fromValue overload instead, reducing the amount of work that needs to happen at runtime. Change-Id: I2aea6aecfee0a9404cbd78dbea01a1d5d3047ca0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qvariant.h')
-rw-r--r--src/corelib/kernel/qvariant.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index 73b7e97792..8f14612bcc 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -435,6 +435,8 @@ public:
static inline QVariant fromValue(const T &value)
#endif
{
+ if constexpr (std::is_null_pointer_v<T>)
+ return QVariant(QMetaType::fromType<std::nullptr_t>());
return QVariant(QMetaType::fromType<T>(), std::addressof(value));
}