#include #include #include #include #include #include #include #include void testTypedefedIterators() { QVector vec; QString str; QVarLengthArray vla; QVector::const_iterator it1 = vec.begin(); // Warning QString::const_iterator it7 = str.begin(); // Warning QString::const_iterator it8 = str.cbegin(); // OK QVarLengthArray::const_iterator it9 = vla.begin(); // Ok, not shared QVarLengthArray::const_iterator it10 = vla.cbegin(); // OK // These are not implemented yet. Can't figure it out.. the QualType doesn't have the typedef information, only T*.. if (vec.cend() == vec.end()) {} // OK if (vec.end() == vec.cend()) {} // Warning if (vec.cend() == vec.cend()) {} // OK if (vec.end() == vec.end()) {} // OK str.begin() == str.cbegin(); // Warning vla.begin() == vla.cbegin(); // OK, not shared } void test() { QMap map; QHash hash; QList list; QSet set; QList::const_iterator it2 = list.begin(); // Warning QHash::const_iterator it3 = hash.begin(); // Warning QHash::const_iterator it4 = hash.cbegin(); // OK QMap::const_iterator it5 = map.begin(); // Warning QMap::const_iterator it6 = map.cbegin(); // OK QSet::const_iterator it11 = set.begin(); // Warning it11 = set.cbegin(); // OK hash.begin() == hash.cbegin(); // Warning list.begin() == list.cbegin(); // Warning set.begin() == set.cbegin(); // Warning map.begin() == map.cbegin(); // Warning hash.begin() == hash.begin(); // OK list.begin() == list.begin(); // OK set.begin() == set.begin(); // OK map.begin() == map.begin(); // OK hash.cbegin() == hash.cbegin(); // OK list.cbegin() == list.cbegin(); // OK set.cbegin() == set.cbegin(); // OK map.cbegin() == map.cbegin(); // OK QHash::const_iterator it12 = QHash::const_iterator(hash.begin()); // OK } void test2() { QVector v; v.erase(std::remove_if(v.begin(), v.end(), [](int){ return false; }), v.end()); // OK QVarLengthArray vla; vla.erase(std::remove_if(vla.begin(), vla.end(), [](int){ return false; }), vla.end()); // OK, not implicit shared } void testStdVector() { std::vector v; std::vector::const_iterator it = v.begin(); // OK } struct Bar { bool foo() const { return mFooIt != mFoo.end(); // OK, since mFooIt is a member, it won't make anything detach } QVector mFoo; QVector::iterator mFooIt; };