Remove default argument from declarations of qHash as friend

It's illegal in C++11: §8.3.6.4 [dcl.fct.default]
"If a friend declaration specifies a default argument expression,
that declaration shall be a definition and shall be the only declaration
of the function or function template in the translation unit."

Clang is starting to enforce this, thus it's making qtbase not compiling.

Task-number: QTBUG-32100
Change-Id: Ifd9d4f62354d7cf4ccf275f36aab64e05c59efff
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
Giuseppe D'Angelo 2013-06-28 21:52:51 +02:00 committed by The Qt Project
parent 6177a3026b
commit 658dfef500
3 changed files with 14 additions and 3 deletions

View File

@ -114,6 +114,10 @@ public:
template<typename E1, typename E2>
class QTypeInfo<QUrlTwoFlags<E1, E2> > : public QTypeInfoMerger<QUrlTwoFlags<E1, E2>, E1, E2> {};
class QUrl;
// qHash is a friend, but we can't use default arguments for friends (§8.3.6.4)
Q_CORE_EXPORT uint qHash(const QUrl &url, uint seed = 0) Q_DECL_NOTHROW;
class Q_CORE_EXPORT QUrl
{
public:
@ -324,7 +328,7 @@ public:
static QList<QUrl> fromStringList(const QStringList &uris, ParsingMode mode = TolerantMode);
static void setIdnWhitelist(const QStringList &);
friend Q_CORE_EXPORT uint qHash(const QUrl &url, uint seed = 0) Q_DECL_NOTHROW;
friend Q_CORE_EXPORT uint qHash(const QUrl &url, uint seed) Q_DECL_NOTHROW;
private:
QUrlPrivate *d;

View File

@ -98,6 +98,9 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QModelIndex &);
class QPersistentModelIndexData;
// qHash is a friend, but we can't use default arguments for friends (§8.3.6.4)
uint qHash(const QPersistentModelIndex &index, uint seed = 0);
class Q_CORE_EXPORT QPersistentModelIndex
{
public:
@ -128,7 +131,7 @@ public:
bool isValid() const;
private:
QPersistentModelIndexData *d;
friend uint qHash(const QPersistentModelIndex &, uint seed = 0);
friend uint qHash(const QPersistentModelIndex &, uint seed);
#ifndef QT_NO_DEBUG_STREAM
friend Q_CORE_EXPORT QDebug operator<<(QDebug, const QPersistentModelIndex &);
#endif

View File

@ -64,6 +64,10 @@ public:
typedef QIPv6Address Q_IPV6ADDR;
class QHostAddress;
// qHash is a friend, but we can't use default arguments for friends (§8.3.6.4)
Q_NETWORK_EXPORT uint qHash(const QHostAddress &key, uint seed = 0);
class Q_NETWORK_EXPORT QHostAddress
{
public:
@ -121,7 +125,7 @@ public:
static QPair<QHostAddress, int> parseSubnet(const QString &subnet);
friend Q_NETWORK_EXPORT uint qHash(const QHostAddress &key, uint seed = 0);
friend Q_NETWORK_EXPORT uint qHash(const QHostAddress &key, uint seed);
protected:
QScopedPointer<QHostAddressPrivate> d;
};