I am processing CSV and using the following code to process a single line.
std::vector<std::string> string_to_vector(const std::string& s, const char delimiter, const char escape) {
  std::stringstream sstr{s};
  std::vector<std::string> result;
  while (sstr.good()) {
    std::string substr;
    getline(sstr, substr, delimiter);
    while (substr.back() == escape) {
      std::string tmp;
      getline(sstr, tmp, delimiter);
      substr += "," + tmp;
    }
    result.emplace_back(substr);
  }
  return result;
}
What it does: Function breaks up string s based on delimiter. If the delimiter is escaped with escape the delimiter will be ignored.
This code works but is super slow. How can I speed it up?
Do you know any existing csv processing implementation that does exactly this and which I could use?
 
    