QDirListing::const_iterator Class
class QDirListing::const_iterator该类在 Qt 6.8 中引入。
- 所有成员(包括继承成员)的列表
- const_iterator 是Input/Output 和 Networking 的一部分。
公共类型
公共函数
QDirListing::const_iterator::reference | operator*() const |
QDirListing::const_iterator & | operator++() |
void | operator++(int) |
QDirListing::const_iterator::pointer | operator->() const |
详细说明
由QDirListing::cbegin() 返回的迭代器类型。
- 这是一个只向前传递的单程迭代器(不能按相反顺序迭代目录条目)
- 不能复制,只能
std::move()
d。 - 在以
std::input_iterator
为模型的对象上,post-increment 的返回值是部分形成的(一个迭代器的副本,该迭代器已被向前推进),对这样的对象进行的唯一有效操作是销毁和分配一个新的迭代器。因此,post-increment 操作符将迭代器向前推进并返回void
。 - 不允许随机访问
- 可用于 ranged-for 循环;或用于不需要随机访问迭代器的 C++20 std::ranges 算法。
- 取消引用一个有效的迭代器会返回一个
const DirEntry &
- (c)end() 返回一个表示迭代结束的QDirListing::sentinel 。取消引用一个比较等于end() 的迭代器是未定义的行为
注意: "经典 "的 STL 算法不支持迭代器/哨兵,因此您需要使用 C++20 std::ranges 算法QDirListing ,或者使用 C++17 中提供基于范围算法的第三方库。
另请参见 QDirListing,QDirListing::sentinel, 和QDirListing::DirEntry 。
成员类型文档
[alias]
const_iterator::pointer
const QDirListing::DirEntry *
的类型定义。
[alias]
const_iterator::reference
const QDirListing::DirEntry &
的类型定义。
成员函数文档
QDirListing::const_iterator::reference const_iterator::operator*() const
返回该迭代器指向的目录条目的const QDirListing::DirEntry &
。
QDirListing::const_iterator &const_iterator::operator++()
预增操作符。将迭代器向前推进并返回一个引用。
void const_iterator::operator++(int)
后增加操作符。
QDirListing::const_iterator 后递增操作符以 C++20std::input_iterator 为模型,也就是说,它是一个只允许移动、只允许前进、只允许单程的迭代器,不允许随机访问。
在以std::input_iterator
为模型的对象上,post-increment 的返回值是部分形成的(一个迭代器的副本,该迭代器已被向前推进),对这样的对象进行的唯一有效操作是销毁和分配一个新的迭代器。因此,post-increment 操作符将迭代器向前推进,并返回void
。
QDirListing::const_iterator::pointer const_iterator::operator->() const
返回该迭代器指向的目录条目的const QDirListing::DirEntry *
。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.