Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
split string
void split(const std::string &s,
const std::string &delim,
const std::function<void(const std::string &)> &f) {
std::string::size_type m{}, n{};
while (true) {
n = s.find(delim, m);
f(s.substr(m, n - m));
if (n == std::string::npos) {
m = n + delim.size();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment