如何解决在哪个 ISO C++ 版本中引入了迭代器?
当迭代器被引入 ISO C++ 时,我正在寻找一个参考,我可以注意到在这个例子中它们自 C++98 以来与向量一起使用,但我从 www.isocpp.com 页面读到这是不是官方文档,只是参考:http://www.cplusplus.com/reference/vector/vector/vector/
// constructing vectors
#include <iostream>
#include <vector>
int main ()
{
// constructors used in the same order as described above:
std::vector<int> first; // empty vector of ints
std::vector<int> second (4,100); // four ints with value 100
std::vector<int> third (second.begin(),second.end()); // iterating through second
std::vector<int> fourth (third); // a copy of third
// the iterator constructor can also be used to construct from arrays:
int myints[] = {16,2,77,29};
std::vector<int> fifth (myints,myints + sizeof(myints) / sizeof(int) );
std::cout << "The contents of fifth are:";
for (std::vector<int>::iterator it = fifth.begin(); it != fifth.end(); ++it)
std::cout << ' ' << *it;
std::cout << '\n';
return 0;
}
我也想找一个官方文档,比如ISO版本,但是不知道买哪个,从哪里买。
是否有按版本列出所有功能的页面?我一直在寻找类似的东西,但我只找到了从 C++11 开始的文档:https://en.cppreference.com/w/cpp/compiler_support
解决方法
迭代器一直追溯到 ISO/IEC 14882:1998 (C++98)。使用 link to the C++98 draft 中的 here,可以看到它有第 24 章迭代器库1,其中详细说明了迭代器要求、std::iterator_traits
和 {{ 1}} 在里面。
1:标准第509页,PDF第535页
,在许多其他版本的信息中,https://en.cppreference.com/w/cpp/language/history 说:
1998 C++98 (ISO/IEC 14882:1998)
- 新功能:RTTI(dynamic_cast、typeid)、协变返回类型、转换运算符、可变、bool、条件声明、模板实例化、成员模板、导出
- 库添加:语言环境、bitset、valarray、auto_ptr、模板化字符串、iostream 和 complex。
- 基于 STL:容器、算法、迭代器、函数对象
因此,迭代器在 1992 年创建的 STL 中,并在 1998 年标准化。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。