build tuple from regex

Home / Uncategorized / build tuple from regex

I have a group of regexes and I have to map their capture groups to function arguments. It seems to me that the easiest thing would be to build a tuple from the regexes capture groups and use std::apply with that. So I am trying to get a template to convert the regex into a tuple, but I am not getting it to work. Below is what I have. I tried specializing the recursion, but it seems like there is no way to specialize a function template. I am fairly new to templating, so any help is welcome =)
string get_value(std::smatch& rx) {
return rx[i];

auto tuple_from_rx(std::smatch& rx) {
if (i > 0) {
return std::tuple_cat(tuple_from_rx(rx), get_value(rx));
else {
return std::tuple<>();


Read more

Leave a Reply

Your email address will not be published. Required fields are marked *