Make QDirListing::const_iterator post-increment return void

std::weakly_incrementable doesn't require a std::input_iterator's
post-increment operator to return anything¹, so don't.

¹ https://eel.is/c++draft/iterator.concepts#iterator.concept.winc-14

The return value of post-increment on objects that model
input_iterator is partially-formed (as a copy of an iterator since
advanced), so any attempts to use it, apart from assigning a new
iterator or destroying it, are undefined, anyway.

Found in API-review.

Change-Id: If0c07250cec4e48c6e5176cd23864651e8ec3d27
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit fd89fc8c27460e2c11d9e3decc38cf61c186f984)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2024-09-02 15:55:21 +02:00 committed by Qt Cherry-pick Bot
parent 5cb51e4afe
commit a1d4c64715

View File

@ -116,7 +116,7 @@ public:
reference operator*() const { return dirEntry; }
pointer operator->() const { return &dirEntry; }
Q_CORE_EXPORT const_iterator &operator++();
const_iterator operator++(int) { auto tmp = *this; operator++(); return tmp; };
void operator++(int) { ++*this; }; // [iterator.concept.winc]/14 not required to return sth
private:
bool atEnd() const noexcept { return dirEntry.dirListPtr == nullptr; }
friend bool operator==(const const_iterator &lhs, sentinel) noexcept { return lhs.atEnd(); }