parsed as non-type error

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

 



Hi,

This is just an academic question, but what exactly is causing this error:

test.cc:31: error: dependent-name
'std::map<int,TYPE,std::less<int>,std::allocator<std::pair<const int,
TYPE> > >::iterator' is parsed as a non-type, but instantiation yields
a type
test.cc:31: note: say 'typename
std::map<int,TYPE,std::less<int>,std::allocator<std::pair<const int,
TYPE> > >::iterator' if a type is meant

When trying to compile this function:

template<typename TYPE>
void
printMembers( std::map< int, TYPE > pmap )
{
   std::map< int, TYPE >::iterator iter ;
   for( iter = pmap.begin() ; iter != pmap.end() ; iter++ )
   {
       std::cerr << "Key: " << iter->first << " Value: " <<
iter->second << std::endl ;
   }
}

The notice made it obvious how to fix, but I haven't been able to find
an actual explanation of what causes the problem.

Thanks,
Paul

[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