There is a project that needs to write a CSV file to render the data. GitHub has a lightweight read and write library about CSV minicsv, so download it. However, the following problems occurred while compiling the example:
In the file included from example.cpp:1:0:
minicsv.hpp:In function ' csv::ofstream& operator<< (csv::ofstream&, const t&) ':
Minicsv.hpp:326:38:error:no matching function for call to ' Csv::ofstream::escape_and_output (std::basic_ostringstream <char>::__string_type) '
Ostm.escape_and_output (Os_temp.str ());
^
Minicsv.hpp:326:38:note:candidate is:
Minicsv.hpp:266:8: Note:void csv::ofstream::escape_and_output (std::string&)
void Escape_and_output (std::string & SRC)
...
A lot of mistakes, no longer posted, occupy space. All of these errors come from the same function header. This function header is defined in this way:
void Escape_and_output (std::string & SRC)
And the call is like this:
Ostm.escape_and_output (Os_temp.str ());
Obviously, the function header required by the call is a reference to the right value, and the true function header gives a reference to the left value, which does not match, and the compiler complains. The modification is very simple, "&" changed to "&" can be, that is, to change the head of the function to look like this:
void Escape_and_output (std::string & src)
Error very water, would not want to Write out, but also afraid of c++0x unfamiliar people will be overwhelmed, so paste it. And I don't know why there's such an obvious mistake in the project-maybe the boss's compiler is too smart.