stl container as template argument
let's say I have a function like this:
Code:
template<typename ContainerT, typename ValueT>
void foo(const ContainerT<ValueT>& c)
{
typedef ContainerT<ValueT> type;
for (type::iterator it = c.begin(); it != c.end(); ++it)
{
// do some stuff
}
}
and I would call it as follows:
Code:
std::vector<int> intVector;
std::list<std::string> stringList;
foo(intVector);
foo(stringList);
obviously this will not compile, because the compiler has no way of knowing that ContainerT is a template type.
is there any way to make something like this work?