Skip to content

Instantly share code, notes, and snippets.

@rep-movsd
Last active May 16, 2016 20:06
Show Gist options
  • Save rep-movsd/53427e6ed83925f656a949f802e145cf to your computer and use it in GitHub Desktop.
Save rep-movsd/53427e6ed83925f656a949f802e145cf to your computer and use it in GitHub Desktop.
Generic splitter
vector<string> split(const string& s, string seps=" ")
{
vector<string> ret;
for(auto ps = &s[0], pd = ps, pe = ps + int(s.size()); ps < pe; ps = pd + 1)
{
ret.emplace_back(string(ps, pd = find_first_of(ps, pe, begin(seps), end(seps))));
}
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment