Skip to content

Instantly share code, notes, and snippets.

@liuml07
Last active December 17, 2015 22:09
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 liuml07/5679889 to your computer and use it in GitHub Desktop.
Save liuml07/5679889 to your computer and use it in GitHub Desktop.
The missing std::string::split() function
vector<string> split(const string &str, const char delim = ' ') {
stringstream ss(str);
vector<string> strvec;
string tmp;
while (std::getline(str, tmp, delim))
strvec.push_back(tmp);
return strvec; // std::move()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment