J'ai une fonction qui compilait très bien sous linux, mais pas moyen de
la compiler avec devCpp. Quelqu'un saurait pourquoi il la refuse ?
template <class _U1, class _V1>
std::ostream & operator << (std::ostream & chaine, std::vector<std::pair< _U1, _V1> > & which)
{
std::vector< std::pair< _U1, _V1> >::iterator it; // <=== L'erreur est ici:
// expected `;' before "it"
// `it' undeclared (first use this function)
for (it = which.begin() ; it != which.end() ; it++)
{
chaine << it->first << " = " << it->second << std::endl;
}
return chaine;
}
Il n'y a aucun problème si je déclare ca:
std::vector< std::pair< int, string> >::iterator it;
Donc où est le problème avec les templates et DevCpp ?