Skip to content

Instantly share code, notes, and snippets.

@hnrck
Created April 17, 2021 14:08
Show Gist options
  • Save hnrck/f983e9c349f01f241b4f0f499147d119 to your computer and use it in GitHub Desktop.
Save hnrck/f983e9c349f01f241b4f0f499147d119 to your computer and use it in GitHub Desktop.
using token_t = std::string;
using tokens_t = std::vector<std::string>;
static inline auto tokenize(const std::string &line, char delimiter) -> tokens_t {
auto tokens = tokens_t{};
auto ss = std::stringstream{line};
auto token = token_t{};
while (std::getline(ss, token, delimiter)) {
if (!token.empty()) {
tokens.push_back(token);
}
}
return tokens;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment