2

I'm looking for a reference when iterators were introduced to the ISO C++, I can notice in this example they are used with vectors since C++98, but I read from the www.isocpp.com page that this is not official documentation but only a reference: 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;
}

Also I want to find an official document like the ISO version but then I don't know which one to buy and where to buy it from.

Is there a page where all features are listed by version? I've look for something similar but I only found this documentation that starts from C++11: https://en.cppreference.com/w/cpp/compiler_support

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Wambitz
  • 355
  • 1
  • 2
  • 13
  • 2
    cppreference tends to have very specific version information, it's a great reference. – tadman Apr 06 '21 at 22:56
  • 1
    If where to get a copy of the Standard revisions is not covered at https://isocpp.org/ they're really missing a marketing opportunity. – user4581301 Apr 06 '21 at 23:00
  • cppreference also has [this lovely page](https://en.cppreference.com/w/cpp/links) which maps Standard drafts to the closest released Standard. The differences are usually minimal and "good enough" for most perusing. – user4581301 Apr 06 '21 at 23:01
  • 4
    https://en.cppreference.com/w/cpp/language/history says: `1998 C++98 (ISO/IEC 14882:1998)` `New features: RTTI (dynamic_cast, typeid), covariant return types, cast operators, mutable, bool, declarations in conditions, template instantiations, member templates, export` `Library additions: locales, bitset, valarray, auto_ptr, templatized string, iostream, and complex.` `Based on STL: containers, algorithms, iterators, function objects` – Jerry Jeremiah Apr 06 '21 at 23:01
  • 1
    Big table back to C++03 scroll down to __Member function table__ https://en.cppreference.com/w/cpp/container – Richard Critten Apr 06 '21 at 23:01
  • 1
    Thank you for your comment @tadman, I already check cppreference, it looked for iterators and vectors, it mentions when some features were introduced in C++11 but it doesn't say they were available since C++98, I'm assuming they do since it's not specified any different. At last it would be nice to have an official document or reference. Thanks! – Wambitz Apr 06 '21 at 23:03
  • 1
    [Link to current running draft](http://eel.is/c++draft/) – user4581301 Apr 06 '21 at 23:03
  • 1
    Yes I checked ccpreference and they did not mention it – Yash Apr 06 '21 at 23:03
  • 1
    @JerryJeremiah Make that an answer – Yash Apr 06 '21 at 23:03

2 Answers2

6

Iterators go all the way back to ISO/IEC 14882:1998 (C++98). Using the link to the C++98 draft from here, can see that it has chapter 24 Iterators library in it1 and there it details the iterator requirements, std::iterator_traits, and std::iterator in it.

1: page 509 of the standard, page 535 of the PDF

NathanOliver
  • 171,901
  • 28
  • 288
  • 402
1

Among the info about many other versions, https://en.cppreference.com/w/cpp/language/history says:

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

  1. New features: RTTI (dynamic_cast, typeid), covariant return types, cast operators, mutable, bool, declarations in conditions, template instantiations, member templates, export
  2. Library additions: locales, bitset, valarray, auto_ptr, templatized string, iostream, and complex.
  3. Based on STL: containers, algorithms, iterators, function objects

So, iterators were in the STL created in 1992 and were standardized in 1998.

Jerry Jeremiah
  • 9,045
  • 2
  • 23
  • 32