Iterators allow a uniform way to travel through all STL containers.
- Prefer using standard algorithms, instead of crafting your own for loops [1]
- Use const iterators when you are not modifying the contents of a container [2,4]
- Prefer comparing iterators with operator!=, instead of operator< [3]
- Use auto to avoid verbosity and typos when you use iterators [5]
- Don't use iterators into a resized std::vector or std::deque [6]
- If you write iterator-based functions, provide a user-friendly interface on top of them [7]
- Herb Sutter. Exceptional C++ style. 2005. ISBN: 0-201-76042-8. Item 1 guideline: 'Prefer reusing algorithms, particularly standard algorithms (e.g., for_each), instead of crafting your own loops'.
- Herb Sutter. Exceptional C++ style. 2005. ISBN: 0-201-76042-8. Item 1 guideline: 'Use const_iterator when you are not modifying the contents of a container'.
- Herb Sutter. Exceptional C++ style. 2005. ISBN: 0-201-76042-8. Item 1 guideline: 'Prefer comparing iterators with !=, not <'.
- Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 31.6. Advice. page 924: '[16] Use const iterators where you don't need to modify the elements of a container'
- Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 31.6. Advice. page 924: '[17] Use auto to avoid verbosity and typos when you use iterators'
- Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 31.6. Advice. page 924: '[21] Don't use iterators into a resized vector or deque'
- Gottschling, Peter. Discovering Modern C++: An Intensive Course for Scientists, Engineers, and Programmers. Addison-Wesley Professional, 2015. Chapter 4.1.5: 'If you write iterator-based functions, provide a user-friendly interface on top of them'