Skip to content

Instantly share code, notes, and snippets.

@DavidLudwig
Last active March 12, 2016 23:15
Show Gist options
  • Save DavidLudwig/0d2759b4e5494625271e to your computer and use it in GitHub Desktop.
Save DavidLudwig/0d2759b4e5494625271e to your computer and use it in GitHub Desktop.
#include <boost/utility/string_ref.hpp>
#include <stdio.h>
void process(boost::string_ref part) {
printf("process(\"%s\")\n", part.to_string().c_str());
}
void split(boost::string_ref s, const char delim) {
size_t p;
while (true) {
p = s.find_first_of(delim);
process(s.substr(0,p));
if (p == boost::string_ref::npos) {
break;
}
s.remove_prefix(p + 1);
}
}
int main(int argc, char ** argv) {
for (int i = 1; i < argc; ++i) {
split(argv[i], ';');
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment