From the course: C++ Templates and the STL

Unlock this course with a free trial

Join today to access over 22,400 courses taught by industry experts.

Forward iterators

Forward iterators

- [Instructor] The forward iterator is like a combination of input and output iterators with a few other capabilities. Here I have a working copy of forward iterator dot CPP from chapter three of the exercise files. The forward list is a single linked list type and it's declared here in forward list header, and it's designed to be efficient iterating from beginning to end but not from end to beginning. That's why it's a single linked list and uses a forward iterator that can iterate forward but it can not iterate back from end to beginning. In fact, we have a forward iterator here declared, and if I were to say that IT one is equal to FL one dot end, which would be the end of the list, and then try to decrement the iterator when I build, you'll notice that I get an error that I can not decrement the value of a forward iterator, and that's because the forward iterator hasn't even implemented the decrement operator. So, here we have a simple forward linked list, and when I build and…

Contents