Last active
December 17, 2015 22:09
-
-
Save liuml07/5679889 to your computer and use it in GitHub Desktop.
The missing std::string::split() function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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