I am trying to write a function to extract keys from map using template to be more generic. Been getting "expected ';' before iter" in the declaration of iterator then "'iter' is not declared in this scope. Please help. Here are listing of the function.
template<typename TK, typename TV>
std::vector<TK> extract_map_keys(std::map<TK, TV> const& input_map)
{
std::vector<TK> retval;
map< TK, TV >::iterator iter; // <-- first ERROR
for ( iter = input_map.begin(); iter != input_map.end(); iter ++) { // <-- second ERROR
retval.push_back(iter->first);
}
return retval;
}