Re: gcc 3.3.2 problem with STL MAP container

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

 



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




[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