-
-
Save ilpropheta/0666a599069305552dbd85467b0a8c87 to your computer and use it in GitHub Desktop.
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_view> split(string_view str, const char* delims) | |
{ | |
vector<string_view> ret; | |
string_view::size_type start = 0; | |
auto pos = str.find_first_of(delims, start); | |
while (pos != string_view::npos) | |
{ | |
if (pos != start) | |
{ | |
ret.push_back(str.substr(start, pos - start)); | |
} | |
start = pos + 1; | |
pos = str.find_first_of(delims, start); | |
} | |
if (start < str.length()) | |
ret.push_back(str.substr(start, str.length() - start)); | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment