I have std::map
which its key is an enum like this:
enum class my_enum{a=1,b,c,d};
std::map<my_enum,my_class> my_map;
I want to iterate over the map so I used this for
:
for (auto current_type = (id_type)0;
(int)current_type < 4;
current_type = (my_enum)((int)current_type + 1)){
//do things
}
I think it is rubbish. Do you have a better suggestion?
EDIT:
I am totally aware of using of iterators. I know they are prefereable. However, for some reason, I have to stick to the regular index-based for
.