Common Programming Mistakes: "Take care when erasing elements inside a loop" mixes iterator with const iterator (clazy check)
The example "Take care when erasing elements inside a loop" mixes iterators with const iterators (QMap::erase
takes a const_iterator
and returns an iterator
) and should probably be rewritten to avoid this. The easiest way would be to use a different container e.g. std::map
so that the general lesson is still taught. Otherwise it could be rewritten using indices, or rewritten using erase_if(QMap<Key, T> &map, Predicate pred)