c++ - 为 STL 迭代器定义了哪些运算符?

标签 c++ stl

我真的用谷歌搜索了很多,但我找不到答案。

STL 迭代器重载了哪些运算符?即 list<t>::iterator, vector<t>::iterator, etc .

我知道这些:

  • * - dereference operator

  • ++ - increment operator (both postfix and prefix)

我不知道更多。那么回到最初的问题:哪些运算符被定义为 STL 迭代器?

最佳答案

这取决于迭代器的类别:http://www.cplusplus.com/reference/iterator/iterator/

或者这个链接可能更清楚: http://en.cppreference.com/w/cpp/iterator

正如评论中所建议的,这里是标准的一小部分:

24.2.1 In general

  1. [...]This International Standard defines five categories of iterators, according to the operations defined on them: input iterators, output iterators, forward iterators, bidirectional iterators and random access iterators, as shown below :
Random Access -> Bidirectional -> Forward -> Input
                                          -> Output

例如前向迭代器满足输入迭代器的所有要求。

24.2.2 Iterator

The Iterator requirements form the basis of the iterator concept taxonomy; every iterator satisfies the Iterator requirements. This set of requirements specifies opearations for dereferencing and incrementing an iterator. Most algorithms will require additional operations to read (24.2.3) or write (24.2.4) values, or to provide a richer set of iterator movements.

就像据说迭代器有定义我们可以对它们执行的操作的要求。

关于c++ - 为 STL 迭代器定义了哪些运算符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17992821/

相关文章:

c++ - std::map 发现在 C++ 中不起作用

c++ - 对 STL 的头文件

c++ - 接受容器类型作为输出参数的方法的协议(protocol)/约定

c++ - 在 C++ 中使用 map 时输出顺序错误

c++ - HashMap 直接访问运算符 []

c++ - 为什么 c++11 sleep_for microseconds 实际上休眠了毫秒?

C++:从命令行链接时遇到问题

c++ - 这个宏是什么意思? #define 未使用(x)((x)=(x))

c++ - Boost 和 Pthread 条件变量的区别

c++ - 在 OpenCV 中隐藏鼠标光标