//==code==
#include <iostream>
#include <list>
#include <string>
#include <hash_map.h>

using namespace std;

template<class K>
struct testClass
{
    typedef hash_map<K, int> IntHashMap;
    typedef list<K> KList;
    IntHashMap hm;
    KList kl;

    void operator()(K k)
    {
        hm[k] = 999;
        IntHashMap::iterator itr = hm.find(k);
        cout << itr->second << endl;

        kl.push_back(k);
        KList::iterator it = kl.begin();
        cout << endl << *it << endl;
    }
};

int main()
{
        testClass<int> tc;
        tc(111);
}


//==compile error==
test.cpp: In member function `void testClass<K>::operator()(K)':
test.cpp:19: error: expected `;' before "itr"
test.cpp:20: error: `itr' undeclared (first use this function)
test.cpp:20: error: (Each undeclared identifier is reported only once for each
function it appears in.)
test.cpp:23: error: expected `;' before "it"
test.cpp:24: error: `it' undeclared (first use this function)
test.cpp: In member function `void testClass<K>::operator()(K) [with K = int]':
test.cpp:31:   instantiated from here
test.cpp:19: error: dependent-name `
__gnu_cxx::hash_map<K,int,__gnu_cxx::hash<_Key>,std::equal_to<_Key>,std::allocator<int>
>::iterator' is parsed as a non-type, but instantiation yields a type
test.cpp:19: note: say `typename 
__gnu_cxx::hash_map<K,int,__gnu_cxx::hash<_Key>,std::equal_to<_Key>,std::allocator<int>
>::
iterator' if a type is meant
test.cpp:31:   instantiated from here
test.cpp:23: error: dependent-name ` std::list<K,std::allocator<_CharT>
>::iterator' is parsed as a non-type, but instantiati
on yields a type
test.cpp:23: note: say `typename  std::list<K,std::allocator<_CharT>
>::iterator' if a type is meant


-- 
           Summary: a template parse error
           Product: gcc
           Version: 3.4.4
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hwon at 21cn dot com
  GCC host triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24648

Reply via email to