path: root/src/corelib/kernel
diff options
authorThiago Macieira <>2017-03-09 13:54:56 +0100
committerThiago Macieira <>2017-04-07 17:41:06 +0000
commit795a54ff9688697c033fc5d522f4c50c707d5924 (patch)
tree20468045310d1cc5e65a1faeb2508c96f41eff33 /src/corelib/kernel
parent25d1bbb84939b6960f16e82254fc844839ddfa54 (diff)
QDataStream: add operator<< and >> for std::nullptr_t
std::nullptr_t is nullary: it accepts only one value, nullptr. So we don't need to read or write anything. This commit simply adds the two operators that allow generic code to operate on std::nullptr_t if required. This commit also adds the actual use to QMetaType::load/save, even though there's no change in behavior. [ChangeLog][QtCore][QDataStream] Added operator<< and operator>> overloads that take std::nullptr_t, to facilitate generic code. Change-Id: Iae839f6a131a4f0784bffffd14aa37e7f62d2740 Reviewed-by: Marc Mutz <> Reviewed-by: Lars Knoll <>
Diffstat (limited to 'src/corelib/kernel')
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index fc8d7dcfea..b75f2ad9dc 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -1350,6 +1350,7 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
case QMetaType::QJsonDocument:
return false;
case QMetaType::Nullptr:
+ stream << *static_cast<const std::nullptr_t *>(data);
return true;
case QMetaType::Long:
stream << qlonglong(*static_cast<const long *>(data));
@@ -1573,6 +1574,7 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
case QMetaType::QJsonDocument:
return false;
case QMetaType::Nullptr:
+ stream >> *static_cast<std::nullptr_t *>(data);
return true;
case QMetaType::Long: {
qlonglong l;