Skip to content

Instantly share code, notes, and snippets.

@mostsignificant
Last active October 19, 2021 22:50
Show Gist options
  • Select an option

  • Save mostsignificant/a0fd6730724c196853c937bfd94410e3 to your computer and use it in GitHub Desktop.

Select an option

Save mostsignificant/a0fd6730724c196853c937bfd94410e3 to your computer and use it in GitHub Desktop.
blog-get-option
std::string_view get_option(
const std::vector<std::string_view>& args,
const std::string_view& option_name) {
for (auto it = args.begin(), end = args.end(); it != end; ++it) {
if (*it == option_name)
if (it + 1 != end)
return *(it + 1);
}
return "";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment