Assume I have:
std::map<K, V1> m1;
std::multimap<K, V2> m2;
I would like to template by container type and by key/value type. The following isn't working however :/
template <typename T>
void do_something(T var)
{
// do something
}
template <typename TContainer, typename TKey, typename TVal>
void func(const TContainer<TKey, TVal>& container)
{
for (typename TContainer<TKey, TVal>::iterator it = container.begin(); it != container.end(); ++it)
{
do_something(it->second);
}
}
And then call it with:
func(m1);
func(m2);