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>
This commit is contained in:
parent
06c2ffdae7
commit
67385c04ce
@ -103,6 +103,23 @@ QByteArray QCryptographicHash::hash(const QByteArray &data, Algorithm method)
|
||||
return hash(QByteArrayView{data}, method);
|
||||
}
|
||||
|
||||
#include "qdatastream.h"
|
||||
|
||||
# ifndef QT_NO_DATASTREAM
|
||||
# include "qfloat16.h"
|
||||
|
||||
QDataStream &QDataStream::operator>>(qfloat16 &f)
|
||||
{
|
||||
return *this >> reinterpret_cast<qint16&>(f);
|
||||
}
|
||||
|
||||
QDataStream &QDataStream::operator<<(qfloat16 f)
|
||||
{
|
||||
return *this << reinterpret_cast<qint16&>(f);
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
#include "quuid.h"
|
||||
|
||||
QUuid::QUuid(const QString &text)
|
||||
|
@ -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"
|
||||
|
@ -67,6 +67,10 @@ QT_BEGIN_NAMESPACE
|
||||
#pragma qt_no_master_include
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_DATASTREAM
|
||||
class QDataStream;
|
||||
#endif
|
||||
|
||||
class qfloat16
|
||||
{
|
||||
struct Wrap
|
||||
@ -200,6 +204,11 @@ QT_WARNING_DISABLE_FLOAT_COMPARE
|
||||
#undef QF16_MAKE_BOOL_OP_INT
|
||||
|
||||
QT_WARNING_POP
|
||||
|
||||
#ifndef QT_NO_DATASTREAM
|
||||
friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &ds, qfloat16 f);
|
||||
friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &ds, qfloat16 &f);
|
||||
#endif
|
||||
};
|
||||
|
||||
Q_DECLARE_TYPEINFO(qfloat16, Q_PRIMITIVE_TYPE);
|
||||
|
@ -991,20 +991,6 @@ QDataStream &QDataStream::operator>>(double &f)
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\overload
|
||||
\since 5.9
|
||||
|
||||
Reads a floating point number from the stream into \a f,
|
||||
using the standard IEEE 754 format. Returns a reference to the
|
||||
stream.
|
||||
*/
|
||||
QDataStream &QDataStream::operator>>(qfloat16 &f)
|
||||
{
|
||||
return *this >> reinterpret_cast<qint16&>(f);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\overload
|
||||
|
||||
@ -1340,19 +1326,6 @@ QDataStream &QDataStream::operator<<(double f)
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\fn QDataStream &QDataStream::operator<<(qfloat16 f)
|
||||
\overload
|
||||
\since 5.9
|
||||
|
||||
Writes a floating point number, \a f, to the stream using
|
||||
the standard IEEE 754 format. Returns a reference to the stream.
|
||||
*/
|
||||
QDataStream &QDataStream::operator<<(qfloat16 f)
|
||||
{
|
||||
return *this << reinterpret_cast<qint16&>(f);
|
||||
}
|
||||
|
||||
/*!
|
||||
\overload
|
||||
|
||||
|
@ -51,7 +51,9 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#if QT_CORE_REMOVED_SINCE(6, 3)
|
||||
class qfloat16;
|
||||
#endif
|
||||
class QByteArray;
|
||||
class QIODevice;
|
||||
|
||||
@ -160,8 +162,9 @@ public:
|
||||
QDataStream &operator>>(std::nullptr_t &ptr) { ptr = nullptr; return *this; }
|
||||
|
||||
QDataStream &operator>>(bool &i);
|
||||
// ### Qt 7: remove the operator or make qfloat16 fully defined, see QTBUG-93499
|
||||
#if QT_CORE_REMOVED_SINCE(6, 3)
|
||||
QDataStream &operator>>(qfloat16 &f);
|
||||
#endif
|
||||
QDataStream &operator>>(float &f);
|
||||
QDataStream &operator>>(double &f);
|
||||
QDataStream &operator>>(char *&str);
|
||||
@ -179,8 +182,9 @@ public:
|
||||
QDataStream &operator<<(quint64 i);
|
||||
QDataStream &operator<<(std::nullptr_t) { return *this; }
|
||||
QDataStream &operator<<(bool i);
|
||||
// ### Qt 7: remove the operator or make qfloat16 fully defined, see QTBUG-93499
|
||||
#if QT_CORE_REMOVED_SINCE(6, 3)
|
||||
QDataStream &operator<<(qfloat16 f);
|
||||
#endif
|
||||
QDataStream &operator<<(float f);
|
||||
QDataStream &operator<<(double f);
|
||||
QDataStream &operator<<(const char *str);
|
||||
|
Loading…
Reference in New Issue
Block a user