Bug 24811 - Wrong compile template class with itetrator inside this class.See example.
Summary: Wrong compile template class with itetrator inside this class.See example.
Status: VERIFIED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P3 major
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-11 20:21 UTC by Andrey Luzin
Modified: 2005-11-11 20:33 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Luzin 2005-11-11 20:21:57 UTC
This Source:
  template <typename Key,typename Value>
27  class mutant_iter
28   {
29   private:
30   std::vector<Value> *Vector;
31   std::multimap<Key,int> *Mmap;
32   std::multimap<Key,int>::iterator iter;
33   };
try to compile:

g++ src.cpp  -pedantic -Wall -o bin

GCC print: 

mutant.cpp:32: error: expected ‘;’ before ‘iter’

Other compilers( Borland C++ Bilder 6.0 for example) compile this sorce correctly.

Modify this source:

27  class mutant_iter
28   {
29   private:
30   std::vector<Value> *Vector;
31   std::multimap<Key,int> *Mmap;
32   std::multimap<Key,int>::iterator; //without iterator name!
33   };

compiled correctly, witout errors or warnings.
Comment 1 Andrew Pinski 2005-11-11 20:24:01 UTC
std::multimap<Key,int>::iterator iter;


You forgot the typename keyword as std::multimap<Key,int> is dependent.

So your source should look like:
  template <typename Key,typename Value>
class mutant_iter
{
private:
  std::vector<Value> *Vector;
  std::multimap<Key,int> *Mmap;
  typename std::multimap<Key,int>::iterator iter;
};


Comment 2 Andrey Luzin 2005-11-11 20:33:24 UTC
It's true. Tanks.