Skip to content

Instantly share code, notes, and snippets.

@nabijaczleweli
Created September 14, 2015 16:30
Show Gist options
  • Save nabijaczleweli/e926a7cdf2ad85e34d70 to your computer and use it in GitHub Desktop.
Save nabijaczleweli/e926a7cdf2ad85e34d70 to your computer and use it in GitHub Desktop.
static-const-nontrivial-init
void strip_line(string & line) {
static const vector<regex> regices = [&]() {
vector<regex> temp(3);
for(const auto reg : {"#.*", " +$", "^ +"}) // comment, start-of-line space, end-of-line space
temp.emplace_back(reg, regex_constants::optimize);
return temp;
}(); // <-- any better way of doing this?
for(const auto & rgx : regices)
line = regex_replace(line, rgx, "");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment