输入迭代器和只读前向迭代器有什么区别?
输入迭代器和只读前向迭代器有什么区别?
因为后者是只读的,所以它们显然不能满足输出迭代器的要求。并且,正因为如此,它们实际上是具有额外保证(如果有)的输入迭代器。问题是,还有什么额外保障呢?
我的猜测是,前向迭代器是多遍的,而输入迭代器不是,对吗?
What's the difference between input iterators and read-only forward iterators?
Because the latter are read-only, they obviously don't satisfy requirements of output iterators. And, because of that, they're effectively input iterators with additional guarantees (if any). The problem is, what additional guarantees?
My guess would be that forward iterators are multi-pass and input iterators are not, am I right?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,输入迭代器是一次性迭代器。您只能对它们进行一次迭代,而前向迭代器可以多次迭代。
来自
§24.2.3 [input.iterators] p2(表)
,++r
的前置/后置条件列:最后一个后置条件意味着对于
a == b
,++a == ++b
不需要为true
。同一条,第 3 段:
来自
§24.2.5 [forward.iterators]
Yes, input iterators are one-pass iterators. You can only iterate over them once, while forward iterators are multi-pass.
From
§24.2.3 [input.iterators] p2 (the table)
, pre-/postcondition column of++r
:The last postcondition implies that for
a == b
,++a == ++b
is not required to betrue
.Same clause, paragraph 3:
From
§24.2.5 [forward.iterators]