diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h index cf0cd4b155..2319a78877 100644 --- a/src/corelib/global/qflags.h +++ b/src/corelib/global/qflags.h @@ -97,8 +97,6 @@ class QFlags struct Private; typedef int (Private::*Zero); #endif - template friend QDataStream &operator>>(QDataStream &, QFlags &); - template friend QDataStream &operator<<(QDataStream &, QFlags); public: #if defined(Q_CC_MSVC) || defined(Q_CLANG_QDOC) // see above for MSVC diff --git a/src/corelib/serialization/qdatastream.h b/src/corelib/serialization/qdatastream.h index 93eaaff43b..3a234ab15e 100644 --- a/src/corelib/serialization/qdatastream.h +++ b/src/corelib/serialization/qdatastream.h @@ -396,11 +396,16 @@ inline QDataStream &QDataStream::operator<<(quint64 i) template inline QDataStream &operator<<(QDataStream &s, QFlags e) -{ return s << e.i; } +{ return s << typename QFlags::Int(e); } template inline QDataStream &operator>>(QDataStream &s, QFlags &e) -{ return s >> e.i; } +{ + typename QFlags::Int i; + s >> i; + e = QFlag(i); + return s; +} template typename std::enable_if_t::value, QDataStream &>