Bonjour,
Affin de faire une fonctions plus générique, j'aurais besoins d'assigner d'assigner std::cin vers un ifstream. Comme ça, je lirais dans mon ifstream, et je lirais soit l'entrée standart, soit le fichier.
J'ai essayer :
Mais j'obtiens cette erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 if (name == "") { f.rdbuf(std::cin.rdbuf()); return; }
Merci pour vos réponsesParser.cpp:22:31: error: no matching function for call to ‘std::basic_ifstream<char>::rdbuf(std::basic_streambuf<char>*)’
f.rdbuf(std::cin.rdbuf());
^
Parser.cpp:22:31: note: candidate is:
In file included from Parser.cpp:13:0:
/usr/include/c++/4.8/fstream:509:7: note: std::basic_ifstream<_CharT, _Traits>::__filebuf_type* std::basic_ifstream<_CharT, _Traits>::rdbuf() const [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ifstream<_CharT, _Traits>::__filebuf_type = std::basic_filebuf<char>]
rdbuf() const
^
/usr/include/c++/4.8/fstream:509:7: note: candidate expects 0 arguments, 1 provided
Partager