Skip to content

Instantly share code, notes, and snippets.

View inhzus's full-sized avatar
🎯
Coding

Inhzus inhzus

🎯
Coding
  • Shopee
  • Beijing, China
View GitHub Profile
@inhzus
inhzus / string_split.cc
Created November 12, 2019 15:39
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) {
break;
}