gcc 3.3.2 problem with STL MAP container

corey taylor corey.taylor@gmail.com
Tue Feb 8 17:59:00 GMT 2005


Morten,

Yes, you could even write the keyword 'typename' in the for statement.

Did you read the 3rd C++ bullet at http://gcc.gnu.org/gcc-3.4/changes.html?

Basically, it is saying that any type from a template parameter, must
be explicitly marked as such with the 'typename' keyword.

corey


On Mon, 07 Feb 2005 19:54:58 +0100, Morten.Gulbrandsen
<f1000mhz@yahoo.de> wrote:
> corey taylor wrote:
> 
> >Moten,
> >
> >  I think this is *best* explained by the gcc release notes for 3.4
> >
> >  This release is the first one to throw this as an error and not a
> >warning as you can produce in gcc 3.3.
> >
> >  http://gcc.gnu.org/gcc-3.4/changes.html
> >
> >  Under C++.  The third bullet.
> >
> >  The summary is that you need to explicitly specify that
> >const_iterator with the 'typename' keyword before it.
> >
> >corey
> >
> >
> >
> >
> Thanks,  this should be correct ?
> 
> //
> // Display map properties
> //
> template<class T, class A>
> void ShowMap(const map<T, A>& v)
> {
> 
>   typename  map<T, A>::const_iterator  ci;
> 
>     for ( ci = v.begin();  ci != v.end();  ++ci)
>         cout << ci->first << ": " << ci->second << "\n";
> 
>     cout << endl;
> }
> 
> instead of   incorrect :
> 
> template<class T, class A>
> > void ShowMap(const map<T, A>& v)
> > {
> >   for (map<T, A>::const_iterator ci = v.begin();  //  line  107
> >
> > /*=======================!!=========================*/
> >
> >                                 ci != v.end(); ++ci)
> >         cout << ci->first << ": " << ci->second << "\n";
> >
> >     cout << endl;
> > }
> 
> if this is correct then I have inderstood it,
> 
>  'typename'  was greek to me
> 
> best regards
> 
> Morten Gulbrandsen
> 
>



More information about the Gcc-help mailing list