C++ has some sort of duck typing for types given by template parameters. We have no idea what type DUCK1
and DUCK2
will be, but as long as they can
I'd like to omit writing a template parameter list that is repetitive and mostly meaningless (Just imagine what would happen if there are 7 ducks...)
For that you could use variadic templates and do something like the following:
template
void let_them_quack(DUCK &&d) {
d.quack();
}
template
void let_them_quack(DUCK &&d, Args&& ...args) {
d.quack();
let_them_quack(std::forward(args)...);
}
Live Demo