Skip to content

Instantly share code, notes, and snippets.

@stryku
Last active March 26, 2017 18:56
Show Gist options
  • Save stryku/34ee78d893ab8c605c09ea5e8b79b319 to your computer and use it in GitHub Desktop.
Save stryku/34ee78d893ab8c605c09ea5e8b79b319 to your computer and use it in GitHub Desktop.
namespace details
{
template <typename s, typename current_tokens = tuple<>>
struct tokenize_impl;
template <typename current_tokens>
struct tokenize_impl<string<>, current_tokens>
{
using tokens = current_tokens;
};
template <char ...str_chars, typename current_tokens>
struct tokenize_impl<string<str_chars...>, current_tokens>
{
using str = string<str_chars...>;
using get_token_t = get_token<str>;
using next_tokens = tuple_append<current_tokens, typename get_token_t::result_token>;
using next_string = typename get_token_t::rest_of_string;
using tokens = typename tokenize_impl<next_string, next_tokens>::tokens;
};
}
template <typename s>
using tokenize = typename details::tokenize_impl<s>::tokens;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment