gpt4 book ai didi

c++ - 序列容器的迭代器类型是什么?

转载 作者:搜寻专家 更新时间:2023-10-31 02:12:57 26 4
gpt4 key购买 nike

当我通读The C++ Programming Language时,我发现这一段说

The iterator passed to inserter() must be an iterator into the container. For a sequence container, that implies that it must be a bidirectional iterator (so that you can insert before it). For example, you can’t use inserter() to make an iterator to insert into a forward_list...

所以我开始寻找可以验证此声明的标准的相关部分。但是,我只剩下这一段(23.2.6 [associative.reqmts] 第 6 段)仅与 associative container 相关:

iterator of an associative container is of the bidirectional iterator category...

在标准中哪里可以找到序列容器的迭代器类型?

最佳答案

标准规定对于序列容器分开。例如

对于 forward_­list :

A forward_­list is a container that supports forward iterators and ...

对于 deque :

A deque is a sequence container that supports random access iterators ([random.access.iterators]).

您可以预期序列容器的迭代器类别至少是前向迭代器类别。

关于c++ - 序列容器的迭代器类型是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42036691/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com