[Interest] Strange problem in template class (Iterator as value type of a QHash)
Mandeep Sandhu
mandeepsandhu.chd at gmail.com
Fri Aug 23 18:39:31 CEST 2013
>
>
> Error from Clang:
>
> error: template argument for template type parameter must be a type; did
> you forget 'typename'?
>
It' right, in that I need to use typename 'somewhere', I just didn't know
where (and why).
I finally fixed it doing a typedef of this dependent type, which also makes
it easy to type! :)
template <typename K, typename V>
class TemplateTest
{
typedef typename QLinkedList<V>::iterator iter;
public:
TemplateTest()
{
QHash<K, iter > h;
Q_UNUSED(h);
}
...
There's a nice explanation about 'typename' keyword here:
http://pages.cs.wisc.edu/~driscoll/typename.html
> Note: use proper compiler next time.
>
Note: Using g++, which is a _very_ proper compiler. It even has a
"-pedantic" switch! ;)
$ g++ --version
g++ (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3
Regards,
-mandeep
>
> > 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
> >
> > ,
> > _______________________________________________
> > Interest mailing list
> > Interest at qt-project.org
> > http://lists.qt-project.org/mailman/listinfo/interest
>
>
> --
> Regards,
> Konstantin
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130823/65c81893/attachment.html>
More information about the Interest
mailing list