I am trying to use template template parameters, similar to what is done here and here (and many other places).
#include
template
Pretty sure this is what you're looking for:
template class V, class T, class... Args>
void fn(V& value)
{
// use value here.
}
Invoked simply as:
std::vector v;
fn(v);
And before you ask, yes, you can do it with templates that need more parameters (like std::map<>
, etc), Just make sure Arg...
covers the optionals and you specify the mandatory ones you care about. Such as:
#include
#include
#include
#include
Output
void fn_seq(const V &) [V = vector, T = int, Args = >]
void fn_seq(const V &) [V = list, T = double, Args = >]
void fn_assoc(const C &) [C = map, K = int, V = float, Args = , std::__1::allocator >>]
void fn_assoc(const C &) [C = unordered_map, K = long, V = long, Args = , std::__1::equal_to, std::__1::allocator >>]