const_iterator 类

class QDirListing ::const_iterator

This class was introduced in Qt 6.8.

公共类型

pointer
reference

公共函数

QDirListing::const_iterator::reference operator* () const
QDirListing::const_iterator & operator++ ()
void operator++ (int)
QDirListing::const_iterator::pointer operator-> () const

详细描述

The iterator type returned by QDirListing::cbegin ().

  • This is a forward-only, single-pass iterator (you cannot iterate directory entries in reverse order)
  • Can't be copied, only std::move() d.
  • The return value of post-increment on objects that model std::input_iterator is partially-formed (a copy of an iterator that has since been advanced), the only valid operations on such an object are destruction and assignment of a new iterator. Therefore the post-increment operator advances the iterator and returns void .
  • Doesn't allow random access
  • Can be used in ranged-for loops; or with C++20 std::ranges algorithms that don't require random access iterators
  • Dereferencing a valid iterator returns a const DirEntry &
  • (c) end () 返回 QDirListing::sentinel that signals the end of the iteration. Dereferencing an iterator that compares equal to end () is undefined behavior

注意: The "classical" STL algorithms don't support iterator/sentinel, so you need to use C++20 std::ranges algorithms for QDirListing , or else a 3rd-party library that provides range-based algorithms in C++17.

另请参阅 QDirListing , QDirListing::sentinel ,和 QDirListing::DirEntry .

成员类型文档编制

[alias] const_iterator:: pointer

A typedef for const QDirListing::DirEntry * .

[alias] const_iterator:: reference

A typedef for const QDirListing::DirEntry & .

成员函数文档编制

QDirListing::const_iterator::reference const_iterator:: operator* () const

返回 const QDirListing::DirEntry & of the directory entry this iterator points to.

QDirListing::const_iterator &const_iterator:: operator++ ()

Pre-increment operator. Advances the iterator and returns a reference to it.

void const_iterator:: operator++ ( int )

Post-increment operator.

QDirListing::const_iterator models C++20 std::input_iterator , that is, it is a move-only, forward-only, single-pass iterator, that doesn't allow random access.

The return value of post-increment on objects that model std::input_iterator is partially-formed (a copy of an iterator that has since been advanced), the only valid operations on such an object are destruction and assignment of a new iterator. Therefore the post-increment operator advances the iterator and returns void .

QDirListing::const_iterator::pointer const_iterator:: operator-> () const

返回 const QDirListing::DirEntry * to the directory entry this iterator points to.