gpt4 book ai didi

c++ - 在哪个 ISO C++ 版本中引入了迭代器?

转载 作者:行者123 更新时间:2023-12-05 09:33:52 25 4
gpt4 key购买 nike

当迭代器被引入 ISO C++ 时,我正在寻找一个引用,我可以注意到在这个例子中,自 C++98 以来它们就与 vector 一起使用,但我从 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 , 可以看到它在 1 中有第 24 章迭代器库,其中详细说明了迭代器要求、std::iterator_traitsstd::iterator在里面。

1:标准第509页,PDF第535页

关于c++ - 在哪个 ISO C++ 版本中引入了迭代器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66977477/

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