slight change to how we declare our qHash overload for CValueObject,

which fixes some include order dependency shenanigans when compiling with GCC,
which was caused by the requirement to overload qHash for CCollection
and the way qHash interacts with the dreaded two-phase lookup for C++ templates

refs #81
This commit is contained in:
Mathew Sutcliffe
2014-01-08 00:12:42 +00:00
parent 64e14b7965
commit bc611263e9
2 changed files with 16 additions and 18 deletions

View File

@@ -1,19 +1,6 @@
#ifndef BLACKMISC_VALUEOBJECT_H
#define BLACKMISC_VALUEOBJECT_H
namespace BlackMisc
{
class CValueObject;
}
/*!
* qHash overload, needed for storing CValueObject in a QSet.
* \param value
* \return
*/
// Appears before all #include directives, to workaround an issue with GCC where the overload is not visible in QSet
unsigned int qHash(const BlackMisc::CValueObject &value);
#include "blackmisc/debug.h"
#include <QtDBus/QDBusMetaType>
#include <QString>
@@ -364,6 +351,22 @@ namespace BlackMisc
return variant != uc;
}
/*!
* qHash overload, needed for storing CValueObject in a QSet.
* \param value
* \param seed
* \return
*/
inline uint qHash(const BlackMisc::CValueObject &value, uint seed = 0)
{
return ::qHash(value.getValueHash(), seed);
}
// Needed so that our qHash overload doesn't hide the qHash overloads in the global namespace.
// This will be safe as long as no global qHash has the same signature as ours.
// Alternative would be to qualify all our invokations of the global qHash as ::qHash.
using ::qHash;
} // namespace
#endif // guard