I do things with maps (could be std::map or another map from the standard library, a boost map, a custom map from another library, etc):
template<class T>
void do_map_stuff(T const& t)
{
for(auto const& p: t)
{
do_element_stuff(p.first, p.second);
}
}
// ... or perhaps...
template<class It>
void do_map_it_stuff(It it, It end)
{
while(it != end)
{
do_element_stuff(it->first, it->second);
it++;
}
}
I also have vectors (or perhaps arrays) that I would like to be able to use with (at least one of) these functions, as they act as maps (with indices being keys).
What is the most straightforward way to accomplish this using the standard library and/or boost (besides writing versions of each that work with vectors)?
Does anything change if I'm stuck with an older compiler with support only up to C++17?