#include <QMultiMap>
template <typename TKey, typename TValue>
TKey lastKeyOf(const QMap<TKey, TValue>& map)
{
if (map.isEmpty())
throw something;
return (map.end() - 1).key();
}
The reason I ask is that:
template <typename TKey, typename TValue>
QMultiMap<TKey, TValue>;
inherits QMap<TKey, TValue>
publicly. So if I call:
QMultiMap<int, std::string> multimap;
...
lastKeyOf(multimap);
All the calls inside lastKeyOf
get statically bound to their QMap
versions instead of QMultiMap
versions, since QMap
was not intended for polymorphic use (no virtual destructor).
I am not even sure what is this use called. Is it object slicing?