Home > Backend Development > C#.Net Tutorial > Compilation errors and solutions for the c++ minicsv library

Compilation errors and solutions for the c++ minicsv library

黄舟
Release: 2016-12-14 16:54:27
Original
1387 people have browsed it

There is a project that requires writing csv files to present data. There is a lightweight reading and writing library for csv called minicsv on Github, so I downloaded it. However, the following problems occurred when compiling example:

In 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::__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)

...

 There are many errors, so I won’t post them anymore and take up space. These errors all come from the same function header. The function header is defined like this:

 void escape_and_output(std::string & src)

 And when calling, it looks like this:

  ostm.escape_and_output(os_temp.str());

 Obviously, the function header when calling requires an rvalue reference, and the real function header gives lvalue reference, the two do not match, so the compiler reports an error. The modification is very simple, just change "&" to "&", that is, change the function header to look like this:
  void escape_and_output(std::string & src)
 The error is very obvious. I didn’t want to write it down at first, but I was afraid that people who are not familiar with c++0x would be at a loss, so I posted it. Also, I don't know why there is such an obvious error in the project - maybe the boss's compiler is too smart.

For more related articles, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template