De-inline qfloat16 streaming operators in QDataStream

Which allows us to remove the #include. The qfloat16 operator overloads
in the global namespace are giving some trouble on some compilers, for
reasons unknown (could be compiler bug, could be real). So don't #include
the header anywhere else: let the user choose it.

Task-number: QTBUG-58555
Change-Id: I4c9f691516694b90b08ffffd149ef7dff27d0f6a
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
bb10
Thiago Macieira 2017-01-31 13:16:06 -08:00 committed by Friedemann Kleint
parent bc232b2bef
commit 3ac806b76d
2 changed files with 11 additions and 9 deletions

View File

@ -42,6 +42,7 @@
#if !defined(QT_NO_DATASTREAM) || defined(QT_BOOTSTRAPPED)
#include "qbuffer.h"
#include "qfloat16.h"
#include "qstring.h"
#include <stdio.h>
#include <ctype.h>
@ -975,7 +976,6 @@ QDataStream &QDataStream::operator>>(double &f)
/*!
\fn QDataStream &QDataStream::operator>>(qfloat16 &f)
\overload
\since 5.9
@ -983,6 +983,11 @@ QDataStream &QDataStream::operator>>(double &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
@ -1280,6 +1285,10 @@ QDataStream &QDataStream::operator<<(double f)
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

View File

@ -43,7 +43,6 @@
#include <QtCore/qscopedpointer.h>
#include <QtCore/qiodevice.h>
#include <QtCore/qpair.h>
#include <QtCore/qfloat16.h>
#ifdef Status
#error qdatastream.h must be included before any header file that defines Status
@ -51,7 +50,7 @@
QT_BEGIN_NAMESPACE
class qfloat16;
class QByteArray;
class QIODevice;
@ -348,9 +347,6 @@ inline QDataStream &QDataStream::operator>>(quint32 &i)
inline QDataStream &QDataStream::operator>>(quint64 &i)
{ return *this >> reinterpret_cast<qint64&>(i); }
inline QDataStream &QDataStream::operator>>(qfloat16 &f)
{ return *this >> reinterpret_cast<qint16&>(f); }
inline QDataStream &QDataStream::operator<<(quint8 i)
{ return *this << qint8(i); }
@ -363,9 +359,6 @@ inline QDataStream &QDataStream::operator<<(quint32 i)
inline QDataStream &QDataStream::operator<<(quint64 i)
{ return *this << qint64(i); }
inline QDataStream &QDataStream::operator<<(qfloat16 f)
{ return *this << reinterpret_cast<qint16&>(f); }
template <typename T>
inline QDataStream &operator>>(QDataStream &s, QList<T> &l)
{