diff options
| author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2024-02-16 13:58:04 +0100 |
|---|---|---|
| committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2024-02-20 16:27:20 +0100 |
| commit | 3823e310e39426043dc7f0529a6fba33fe4d49f0 (patch) | |
| tree | 25b0648cb3f043c966966882b13439b0dccc24fb /src/corelib/serialization/qdatastream.cpp | |
| parent | a43d86fe1c0bc9d352f67c134a9ee5f754aea5e6 (diff) | |
QDataStream: reimplement and constrain operator<<(bool)
Instead of offering it as a plain overload, make it a template
and constrain the argument to be precisely bool. This removes the
danger of accidentally streaming things that are convertible to bool,
such as pointers, by, indeed, converting them to bool.
This allows us to remove the deleted overloads for pointers to
objects and pointers to members.
The existing operator<<(bool) is exported, hence I moved it into
removed_api.cpp. Since the implementation required private
QDataStream APIs, I've just "inlined" the implementation that
simply routed through the operator<<(qint8) overload.
Change-Id: I3c0a9811bf5c9e734e28514b37bcaaddb09ada25
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/serialization/qdatastream.cpp')
| -rw-r--r-- | src/corelib/serialization/qdatastream.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/corelib/serialization/qdatastream.cpp b/src/corelib/serialization/qdatastream.cpp index 29fe9978011..14bbae53f43 100644 --- a/src/corelib/serialization/qdatastream.cpp +++ b/src/corelib/serialization/qdatastream.cpp @@ -1267,18 +1267,13 @@ QDataStream &QDataStream::operator<<(qint64 i) */ /*! + \fn QDataStream &QDataStream::operator<<(bool i) + \overload + Writes a boolean value, \a i, to the stream. Returns a reference to the stream. */ -QDataStream &QDataStream::operator<<(bool i) -{ - CHECK_STREAM_WRITE_PRECOND(*this) - if (!dev->putChar(qint8(i))) - q_status = WriteFailed; - return *this; -} - /*! \overload |
