summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qfloat16.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-02-09 10:45:48 +0100
committerMarc Mutz <marc.mutz@qt.io>2022-03-14 15:55:12 +0100
commit67385c04ce272cf553bc2e8aa8e923cd7851fc66 (patch)
tree6fbe4250ed28787282cb1c9a1cc04e555fcd084b /src/corelib/global/qfloat16.cpp
parent06c2ffdae7aecc912b4541a4049ab6aab49cab65 (diff)
QDataStream: make qfloat16 streaming a non-member
Remove the member function from the API and re-add it as a hidden friend on qfloat16, where it will be a complete type. [ChangeLog][QtCore][Potentially Souce-Incompatible Changes] The qfloat16 QDataStream operators are now hidden friends and only found by argument-dependent lookup. Previously, these were member functions on QDataStream. Fixes: QTBUG-93499 Pick-to: 6.3 Change-Id: Ib3d4df7a3fe3a9d0938f3be8b70b50fef0416262 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/global/qfloat16.cpp')
-rw-r--r--src/corelib/global/qfloat16.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/corelib/global/qfloat16.cpp b/src/corelib/global/qfloat16.cpp
index 0eb6ec1010..62c87234a2 100644
--- a/src/corelib/global/qfloat16.cpp
+++ b/src/corelib/global/qfloat16.cpp
@@ -42,6 +42,8 @@
#include "private/qsimd_p.h"
#include <cmath> // for fpclassify()'s return values
+#include <QtCore/qdatastream.h>
+
QT_BEGIN_NAMESPACE
QT_IMPL_METATYPE_EXTERN(qfloat16)
@@ -394,6 +396,41 @@ Q_CORE_EXPORT void qFloatFromFloat16(float *out, const qfloat16 *in, qsizetype l
out[i] = float(in[i]);
}
+#ifndef QT_NO_DATASTREAM
+/*!
+ \fn qfloat16::operator<<(QDataStream &ds, qfloat16 f)
+ \relates QDataStream
+ \since 5.9
+
+ Writes a floating point number, \a f, to the stream \a ds using
+ the standard IEEE 754 format. Returns a reference to the stream.
+
+ \note In Qt versions prior to 6.3, this was a member function on
+ QDataStream.
+*/
+QDataStream &operator<<(QDataStream &ds, qfloat16 f)
+{
+ return ds << f.b16;
+}
+
+/*!
+ \fn qfloat16::operator>>(QDataStream &ds, qfloat16 &f)
+ \relates QDataStream
+ \since 5.9
+
+ Reads a floating point number from the stream \a ds into \a f,
+ using the standard IEEE 754 format. Returns a reference to the
+ stream.
+
+ \note In Qt versions prior to 6.3, this was a member function on
+ QDataStream.
+*/
+QDataStream &operator>>(QDataStream &ds, qfloat16 &f)
+{
+ return ds >> f.b16;
+}
+#endif
+
QT_END_NAMESPACE
#include "qfloat16tables.cpp"