File indexing completed on 2024-04-28 05:38:43

0001 #include <QtCore/QString>
0002 #include <QtCore/QMap>
0003 #include <QtCore/QHash>
0004 #include <QtCore/QVector>
0005 #include <QtCore/QList>
0006 #include <QtCore/QSet>
0007 #include <QtCore/QVarLengthArray>
0008 #include <vector>
0009 void testTypedefedIterators()
0010 {
0011     QVector<int> vec;
0012     QString str;
0013     QVarLengthArray<int, 5> vla;
0014 
0015     QVector<int>::const_iterator it1 = vec.begin(); // Warning
0016     QString::const_iterator it7 = str.begin(); // Warning
0017     QString::const_iterator it8 = str.cbegin(); // OK
0018     QVarLengthArray<int, 5>::const_iterator it9 = vla.begin(); // Ok, not shared
0019     QVarLengthArray<int, 5>::const_iterator it10 = vla.cbegin(); // OK
0020 
0021     // These are not implemented yet. Can't figure it out.. the QualType doesn't have the typedef information, only T*..
0022 
0023     if (vec.cend() == vec.end()) {} // OK
0024     if (vec.end() == vec.cend()) {} // Warning
0025     if (vec.cend() == vec.cend()) {} // OK
0026     if (vec.end() == vec.end()) {} // OK
0027     str.begin() == str.cbegin(); // Warning
0028     vla.begin() == vla.cbegin(); // OK, not shared
0029 }
0030 
0031 void test()
0032 {
0033     QMap<int,int> map;
0034     QHash<int,int> hash;
0035     QList<int> list;
0036     QSet<int> set;
0037 
0038 
0039     QList<int>::const_iterator it2 = list.begin(); // Warning
0040     QHash<int,int>::const_iterator it3 = hash.begin(); // Warning
0041     QHash<int,int>::const_iterator it4 = hash.cbegin(); // OK
0042     QMap<int,int>::const_iterator it5 = map.begin(); // Warning
0043     QMap<int,int>::const_iterator it6 = map.cbegin(); // OK
0044     QSet<int>::const_iterator it11 = set.begin(); // Warning
0045     it11 = set.cbegin(); // OK
0046 
0047     hash.begin() == hash.cbegin(); // Warning
0048     list.begin() == list.cbegin(); // Warning
0049     set.begin() == set.cbegin(); // Warning
0050     map.begin() == map.cbegin(); // Warning
0051 
0052     hash.begin() == hash.begin(); // OK
0053     list.begin() == list.begin(); // OK
0054     set.begin() == set.begin(); // OK
0055     map.begin() == map.begin(); // OK
0056 
0057     hash.cbegin() == hash.cbegin(); // OK
0058     list.cbegin() == list.cbegin(); // OK
0059     set.cbegin() == set.cbegin(); // OK
0060     map.cbegin() == map.cbegin(); // OK
0061 
0062     QHash<int,int>::const_iterator it12 = QHash<int,int>::const_iterator(hash.begin()); // OK
0063 }
0064 
0065 void test2()
0066 {
0067     QVector<int> v;
0068     v.erase(std::remove_if(v.begin(), v.end(), [](int){ return false; }),
0069             v.end()); // OK
0070 
0071     QVarLengthArray<int, 5> vla;
0072     vla.erase(std::remove_if(vla.begin(), vla.end(), [](int){ return false; }),
0073               vla.end()); // OK, not implicit shared
0074 }
0075 
0076 
0077 void testStdVector()
0078 {
0079     std::vector<int> v;
0080     std::vector<int>::const_iterator it = v.begin(); // OK
0081 }
0082 
0083