Re: Iterator over a map of generic vectors.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Greets,

	Before people get too confused here by tangential topics, I'd just
like to reiterate that Ian already answered the original question on 9/8,
simply:  that an (template) argument-dependent nested type (e.g. map<int,
vector<T> >::iterator) requires the 'typename' keyword prefixed.
(Earlier compiler versions didn't require it, a.k.a. implicit typenames,
which is non-standard conforming.)

	See first bullet under: http://gcc.gnu.org/bugs.html#nonbugs_cxx

	The original posted code (below) has nothing to do with template
argument deduction, as was alluded and mentioned in another response.

> "Eric Lance" <eric.lance@xxxxxxxxx> writes:
>
> > I'm trying to figure out if this is a bug or "feature". In a generic
> > function, I want to declare an iterator over a map whose values are
> > generic vectors. However, I get a syntax error whenever I try to
> > declare this particular kind of iterator. The code snippet below
> > should illustrate what I mean better:
> >
> > template<typename T>
> > void func()
> > {
> >     map< int, vector<T> > m;             //we want an iterator over m.
> >     map< int, vector<T> >::iterator i;      //this doesn't compile
> >     map< int, vector<int> >::iterator k;   //but this does
> > }
>
> This is not a gcc question.  In standard C++ you need to say
>   typename map< int, vector<T> >::iterator i;


Fang




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux