PDA

View Full Version : qHash of boost::tuple



west
15th May 2014, 16:09
Hello, I'm trying to put some boost::tuple into the QSet.

The gcc error:

/usr/include/qt4/QtCore/qhash.h:759:36: instantiated from ‘QHash<Key, T>::iterator QHash<Key, T>::insert(const Key&, const T&) [with Key = boost::tuples::tuple<int, int, int>, T = QHashDummyValue]’
/usr/include/qt4/QtCore/qset.h:181:93: instantiated from ‘QSet<T>::const_iterator QSet<T>::insert(const T&) [with T = boost::tuples::tuple<int, int, int>]’
src/xxx.cpp:151:120: instantiated from here
/usr/include/qt4/QtCore/qhash.h:882:24: error: no matching function for call to ‘qHash(const boost::tuples::tuple<int, int, int>&)’


My qHash function:


inline uint qHash(const boost::tuples::tuple<int, int, int>& key) {
return qHash(key.get<0>() + key.get<1>() + key.get<2>());
}

Do you have any clue why my qHash function compiles but isn't seen during the insertion It's defined at the top of xxx.cpp

anda_skoa
16th May 2014, 08:49
Have you tried specifying the template argument?



uint qHash<boost::tuple<int, int, int> >(...)


Cheers,
_

west
16th May 2014, 11:23
I've added


struct TriInt : public boost::tuple<int, int, int>
{
TriInt(int first, int second, int third) : boost::tuple<int, int, int>(first, second, third) {}
};


And it worked :)