J'ai une carte STL de type <string, int>
, je dois copier cette carte dans un fichier, mais je vais avoir du mal à mettre le type de ostream_iterator
Utiliser ostream_iterator pour copier une carte dans le fichier
map<string, int> M;
ofstream out("file.txt");
copy(begin(M), end(M), ostream_iterator<string, int>(out , "\n"));
Error message error: no matching function for call to 'std::ostream_iterator, int>::ostream_iterator(std::ofstream&, const char [2])'|
puisque la carte M est un type, pourquoi ostream_iterator ne prend-il pas son type?
connexes: http://stackoverflow.com/questions/634087/stdcopy-to-stdcout-for-stdpair –