[Development] Future of java-style iterators?

Thiago Macieira thiago.macieira at intel.com
Wed Dec 6 00:01:19 CET 2023


On Tuesday, 5 December 2023 14:02:36 PST Giuseppe D'Angelo via Development 
wrote:
> QDirIterator, QRegularExpressionMatchIterator, (private) QStringIterator
> and similar don't have replacements yet.
> 
> Yes, one can wrap a Java iterator back into a range API (as I've done
> for QREMI, so you can use do `for (auto match : re.globalMatch(subj)`),
> but then one really wants C++20 for the algorithms.

QDirIterator could be rewritten either as an input or a forward Standard 
Library iterator. It wouldn't be a bad idea because its implementation is 
broken: while you're trying to get the information about the current item, 
it's stat()ing the next. It's also hard to guess which element you're getting 
and whether you're accidentally skipping the first entry, or missing the last 
one.

All of which are caused by the fact that it *is* a Java-style iterator.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Cloud Software Architect - Intel DCAI Cloud Engineering
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5163 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20231205/822a32e5/attachment.bin>


More information about the Development mailing list