[Interest] Strange problem in template class (Iterator as value type of a QHash)

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Fri Aug 23 14:43:36 CEST 2013


Hi All,

I'm writing a template class which contains a QHash. Now if I try to store
an Iterator (of a QList) as the _value_ of this Hash then it fails to
compile.

Here's the sample code:

template <typename K, typename V>
class TemplateTest
{
public:
    TemplateTest()
    {
        QHash<K, QLinkedList<V>::iterator > h;
        Q_UNUSED(h);
    }

private:
    K k;
    V v;
};

Error:

templatetest.h:13: error: type/value mismatch at argument 2 in template
parameter list for 'template<class Key, class T> class QHash'
templatetest.h:13: error:   expected a type, got 'QLinkedList<V>::iterator'
templatetest.h:13: error: invalid type in declaration before ';' token

However, if I keep the value as a QList (remove iterator) it compile fine.

Whats the problem with storing a Iterator as the value?

Thanks,
-mandeep
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130823/472f92bd/attachment.html>


More information about the Interest mailing list