Results 1 to 3 of 3

Thread: qHash of boost::tuple

  1. #1
    Join Date
    Feb 2012
    Location
    Warsaw, Poland
    Posts
    37
    Thanks
    3
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default qHash of boost::tuple

    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:
    Qt Code:
    1. inline uint qHash(const boost::tuples::tuple<int, int, int>& key) {
    2. return qHash(key.get<0>() + key.get<1>() + key.get<2>());
    3. }
    To copy to clipboard, switch view to plain text mode 

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qHash of boost::tuple

    Have you tried specifying the template argument?

    Qt Code:
    1. uint qHash<boost::tuple<int, int, int> >(...)
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  3. #3
    Join Date
    Feb 2012
    Location
    Warsaw, Poland
    Posts
    37
    Thanks
    3
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: qHash of boost::tuple

    I've added
    Qt Code:
    1. struct TriInt : public boost::tuple<int, int, int>
    2. {
    3. TriInt(int first, int second, int third) : boost::tuple<int, int, int>(first, second, third) {}
    4. };
    To copy to clipboard, switch view to plain text mode 

    And it worked

Similar Threads

  1. Boost: use it with Qt
    By Handi in forum Installation and Deployment
    Replies: 12
    Last Post: 2nd April 2012, 01:16
  2. QT Roadmap considering Boost and C++0x
    By frank100 in forum Newbie
    Replies: 3
    Last Post: 19th January 2011, 21:59
  3. QT/C++/ BOOST questions
    By joebats72 in forum Newbie
    Replies: 4
    Last Post: 17th January 2011, 23:49
  4. Replies: 1
    Last Post: 10th February 2009, 10:42
  5. Can QHash::capacity() be smaller than QHash::size()?!?
    By iw2nhl in forum Qt Programming
    Replies: 2
    Last Post: 24th August 2007, 02:17

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.