Lets say we have std::map and we want to iterate through. What are advantages/disadvantages ( or what is the main difference ) between this two iterations?
map<string,int> m0 { { "name1", 20 }, { "name2", 30 }, { "name3", 40 } };
for( auto &it : m0 )
it = m0 . erase( it );
and
for (auto it=m0.begin(); it!=m0.end(); )
it = m0.erase(it);
The first code isn't compalible and I don't know why although in cppreference syntax is like the first one.
Aucun commentaire:
Enregistrer un commentaire