D
Daniel =?iso-8859-1?Q?Lidstr=F6m?=
Hi,
is there anything wrong with this template function?
template<class T>
void print_percents(std:stream& stream, int n, T vals)
{
if( !vals.empty() ) {
T::iterator it = vals.begin();
stream << (*it).first << '/' << int(100*((*it).second / n)) << '%';
for( ++ it; it!=vals.end(); ++ it )
stream << ' ' << (*it).first << '/' << int(100*((*it).second / n)) <<
'%';
stream << '\n';
}
}
I can compile it with VC6 but gcc 2.95-3 gives this error:
..src/Hash.h: In function `void print_percents(ostream &, int, T)':
..src/Hash.h:68: parse error before `='
I.e. the line `T::iterator it = vals.begin();'
What's going on?
Thanks!
is there anything wrong with this template function?
template<class T>
void print_percents(std:stream& stream, int n, T vals)
{
if( !vals.empty() ) {
T::iterator it = vals.begin();
stream << (*it).first << '/' << int(100*((*it).second / n)) << '%';
for( ++ it; it!=vals.end(); ++ it )
stream << ' ' << (*it).first << '/' << int(100*((*it).second / n)) <<
'%';
stream << '\n';
}
}
I can compile it with VC6 but gcc 2.95-3 gives this error:
..src/Hash.h: In function `void print_percents(ostream &, int, T)':
..src/Hash.h:68: parse error before `='
I.e. the line `T::iterator it = vals.begin();'
What's going on?
Thanks!