Skip to content

Instantly share code, notes, and snippets.

@yumetodo
Created February 23, 2016 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yumetodo/4059d985e627512a229d to your computer and use it in GitHub Desktop.
Save yumetodo/4059d985e627512a229d to your computer and use it in GitHub Desktop.
std::vector<std::string> split(const std::string &str, char delim) {
std::vector<std::string> res;
std::size_t current = 0, found;
while ((found = str.find_first_of(delim, current)) != std::string::npos) {
res.emplace_back(str, current, found - current);
current = found + 1;
}
res.emplace_back(str, current, str.size() - current);
return res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment