diff --git a/src/blackmisc/collection.h b/src/blackmisc/collection.h index 6144ed051..7d1dda81f 100644 --- a/src/blackmisc/collection.h +++ b/src/blackmisc/collection.h @@ -207,14 +207,17 @@ namespace BlackMisc //! Remove the element pointed to by the given iterator. //! \return An iterator to the position of the next element after the one removed. //! \fixme Relying on implementation detail of QMap to reinterpret_cast to the necessary iterator type. - iterator erase(iterator pos) { return m_impl.erase(reinterpret_cast *&>(pos)); } + iterator erase(iterator pos) + { + return m_impl.erase(const_cast *&>(reinterpret_cast *&>(pos))); + } //! Remove the range of elements between two iterators. //! \return An iterator to the position of the next element after the one removed. //! \fixme Relying on implementation detail of QMap to reinterpret_cast to the necessary iterator type. iterator erase(iterator it1, iterator it2) { - while (it1 != it2) { it1 = m_impl.erase(reinterpret_cast *&>(it1)); } + while (it1 != it2) { it1 = erase(it1); } return it1; }