其中ISO C++;迭代器引入了什么版本? < >我在寻找迭代器引入ISOC+时,我注意到,在这个例子中,它们是用C++自C++ 98来使用的,但是我从页面上读到这不是官方文档,而只是一个引用: //构造向量 #包括 #包括 int main() { //按上述相同顺序使用的构造函数: std::vector first;//整数的空向量 std::vector second(4100);//值为100的四个整数 std::vector third(second.begin(),second.end());//遍历second 向量第四(三);//第三的副本 //迭代器构造函数也可用于从数组构造: int myints[]={16,2,77,29}; 向量第五(myints,myints+sizeof(myints)/sizeof(int)); std::cout

其中ISO C++;迭代器引入了什么版本? < >我在寻找迭代器引入ISOC+时,我注意到,在这个例子中,它们是用C++自C++ 98来使用的,但是我从页面上读到这不是官方文档,而只是一个引用: //构造向量 #包括 #包括 int main() { //按上述相同顺序使用的构造函数: std::vector first;//整数的空向量 std::vector second(4100);//值为100的四个整数 std::vector third(second.begin(),second.end());//遍历second 向量第四(三);//第三的副本 //迭代器构造函数也可用于从数组构造: int myints[]={16,2,77,29}; 向量第五(myints,myints+sizeof(myints)/sizeof(int)); std::cout,c++,C++,迭代器可以追溯到ISO/IEC 14882:1998(C++98)。使用from,可以看到它在it1中有第24章迭代器库,在那里它详细说明了迭代器的要求,std::iterator\u traits和std::iterator 1:标准的第509页,PDF的第535页,在许多其他版本的信息中,说明: 1998 C++98(ISO/IEC 14882-1998) 新特性:RTTI(dynamic_cast,typeid)、协变返回类型、cast运算符、可变、bool、条件声明、模板实例化、成员模板

迭代器可以追溯到ISO/IEC 14882:1998(C++98)。使用from,可以看到它在it1中有第24章迭代器库,在那里它详细说明了迭代器的要求,
std::iterator\u traits
std::iterator


1:标准的第509页,PDF的第535页,在许多其他版本的信息中,说明:

1998 C++98(ISO/IEC 14882-1998)

  • 新特性:RTTI(dynamic_cast,typeid)、协变返回类型、cast运算符、可变、bool、条件声明、模板实例化、成员模板、导出
  • 库添加:区域设置、位集、VALARY、自动ptr、模板化字符串、iostream和complex
  • 基于STL:容器、算法、迭代器、函数对象

  • 因此,迭代器出现在1992年创建的STL中,并在1998年被标准化。

    cppreference往往有非常具体的版本信息,这是一个很好的参考。如果在哪里可以获得标准修订版的副本还没有包括在内,他们真的错过了一个营销机会。比如:
    1998 C++98(ISO/IEC 14882:1998)
    新功能:RTTI(动态转换,类型ID),协变返回类型,强制转换运算符,可变,bool,条件中的声明,模板实例化,成员模板,导出
    库添加:locale,bitset,valarray,auto_ptr,templatized string,iostream和complex。
    基于STL的:容器,算法,迭代器,函数对象
    返回到大表C++03向下滚动到成员函数表感谢您的评论@tadman,我已经检查了cppreference,它查找了迭代器和向量,它提到了C++11中引入的一些功能,但它没有说这些功能自C++98以来就可用,我假设它们可用,因为它没有指定任何不同的内容。最后,如果有这些功能就好了官方文件或参考资料。谢谢!
    // 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;
    }