当迭代器被引入 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;
}
Run Code Online (Sandbox Code Playgroud)
我也想找一份官方文件,比如 ISO 版本,但我不知道该买哪个,从哪里买。
是否有按版本列出所有功能的页面?我一直在寻找类似的东西,但我只找到了从 C++11 开始的这个文档:https : //en.cppreference.com/w/cpp/compiler_support
迭代器一直追溯到 ISO/IEC 14882:1998 (C++98)。使用从这里到 C++98 草案的链接,可以看到它有第 24 章迭代器库1,它详细说明了迭代器要求,和。std::iterator_traitsstd::iterator
1:标准第509页,PDF第535页
| 归档时间: |
|
| 查看次数: |
90 次 |
| 最近记录: |