Why can't I use QList :: size_type since I would be std :: string :: size_type? (template parameter error)

When analyzing an unsigned and integer warning when declaring an iterator in a for loop, I read this :

If possible, use the exact type that you will be comparing (for example, use std::string::size_typewhen comparing with length std::string).

I have QList<T>one that I wanted to iterate by declaring an iterator using the method described above:

 for(QList::size_type i = 0; i < uploads.size(); i++)
 {
     //Do something
 }

And this gave me a compiler error:

error: 'template<class T> class QList' used without template parameters
for(QList::size_type i = 0; i < uploads.size(); i++)

? Qt ? QList::size_type, QList::size() int, ; , , .

+4
2

QList - , , , . QList<int> QList<int>::size_type.

BTW: std::string std:: basic_string, typedef, std::basic_string<char>. , std::string::size_type std::basic_string<char>::size_type.

+7

, . A std::string std::basic_string<char>, .

Qlist ,

QList<some_type>::size_type

, , ,

using QIntList = QList<int>;

ise

QIntList::size_type
+6

Source: https://habr.com/ru/post/1679893/


All Articles