I am working on a recursive map class called group_by
which models the SQL namesake.
For example, gb is a group_by
object
Chained method calls are essentially recursive, so you need to implement at
recursively:
child_type& at( I const& key ) {
return m_map.at( key );
}
template
auto at(const I &i, const J &j, const Ks &...ks)
-> decltype(m_map.at(i).at(j, ks...)) {
return m_map.at(i).at(j, ks...);
}
Note that since at
requires at least 1 argument, the variadic form takes at least 2 parameters. This is significantly easier to implement than dispatching on sizeof...
, and should be easier to read.