I don't see a case where template template parameters would ever be useful, when they could be simply replaced with one template parameter that would work just as well. Referring to my example:
template<template<typename, typename...> typename Cont, typename T, typename... Args>
void Foo(Cont<T, Args...> container)
{
for (auto i : container)
std::cout << i << " ";
std::cout << std::endl;
}
template<typename T>
void Bar(T container)
{
for (auto i : container)
std::cout << i << " ";
std::cout << std::endl;
}
These will function identically, and Bar
will work on any container defining an iterator (allocator not needed). Foo
however, does the same thing, but is a lot more confusing to write (and more confusing to understand). I don't know if I missed the point on template template parameters, but they really seem useless to me as a single template parameter will deduce the type too, albeit without the other parameters.
Also - should I be using typename
or class
for the template template parameter?
template<typename> class T
or
template<typename> typename T