Remove friend declarations that aren't required

Those are problematic as they are also interpreted as
forward declarations of methods that are defined inline in
qdatastream.h and might never get instantiated. This can
lead to problems if template code checks for the existence
of the method.

Change-Id: I4550a6bc70ebd7edc57fe0420b89b453195971d0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Lars Knoll 2020-07-06 17:53:58 +02:00
parent df289c822d
commit 0e6a327f14
2 changed files with 7 additions and 4 deletions

View File

@ -97,8 +97,6 @@ class QFlags
struct Private;
typedef int (Private::*Zero);
#endif
template <typename E> friend QDataStream &operator>>(QDataStream &, QFlags<E> &);
template <typename E> friend QDataStream &operator<<(QDataStream &, QFlags<E>);
public:
#if defined(Q_CC_MSVC) || defined(Q_CLANG_QDOC)
// see above for MSVC

View File

@ -396,11 +396,16 @@ inline QDataStream &QDataStream::operator<<(quint64 i)
template <typename Enum>
inline QDataStream &operator<<(QDataStream &s, QFlags<Enum> e)
{ return s << e.i; }
{ return s << typename QFlags<Enum>::Int(e); }
template <typename Enum>
inline QDataStream &operator>>(QDataStream &s, QFlags<Enum> &e)
{ return s >> e.i; }
{
typename QFlags<Enum>::Int i;
s >> i;
e = QFlag(i);
return s;
}
template <typename T>
typename std::enable_if_t<std::is_enum<T>::value, QDataStream &>