Browse Source
It prevents detachments: To illustrate: QMap<QString, QString> map; /* code compiles and works fine but find() returns the non-const QMap::iterator that detaches! */ QMap<QString, QString>::const_iterator it = map.find("girish"); but also some subtle bugs: QHash<int, int> wrong; if (wrong.find(1) == wrong.cend()) { qDebug() << "Not found"; } else { /* find() detached the container before cend() was called, so it prints "Found" */ qDebug() << "Found"; } QHash<int, int> right; if (right.constFind(1) == right.cend()) { qDebug() << "Not found"; // This is correct now ! } else { qDebug() << "Found"; } Enforced by QT_STRICT_ITERATORS definition.adaptive-webui-19844
Luís Pereira
7 years ago
4 changed files with 5 additions and 4 deletions
Loading…
Reference in new issue