mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-09 21:45:34 +08:00
Fix for undefined behaviour in CCollection::erase.
This commit is contained in:
committed by
Klaus Basan
parent
9c07326462
commit
470a0b27f5
@@ -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<QMapNode<T, T> *&>(pos)); }
|
||||
iterator erase(iterator pos)
|
||||
{
|
||||
return m_impl.erase(const_cast<QMapNode<T, T> *&>(reinterpret_cast<const QMapNode<T, T> *&>(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<QMapNode<T, T> *&>(it1)); }
|
||||
while (it1 != it2) { it1 = erase(it1); }
|
||||
return it1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user