If nothing else, a const_iterator
reads better, since it tells anyone reading the code “I’m just iterating over this container, not messing with the objects contained”.
That’s a great big win, never mind any performance differences.
More Related Contents:
- How to remove constness of const_iterator?
- what is the difference between const_iterator and iterator? [duplicate]
- How to implement an STL-style iterator and avoid common pitfalls?
- Why use iterators instead of array indices?
- Why are Standard iterator ranges [begin, end) instead of [begin, end]?
- What happens if you call erase() on a map element while iterating from begin to end?
- How to correctly implement custom iterators and const_iterators?
- Removing item from vector while iterating?
- comparing iterators from different containers
- Why use non-member begin and end functions in C++11?
- Sorting a vector in descending order
- How are iterators and pointers related?
- What’s faster, iterating an STL vector with vector::iterator or with at()?
- What is the difference between const_iterator and non-const iterator in the C++ STL?
- What is an iterator’s default value?
- Custom Iterator in C++
- Why is “!=” used with iterators instead of “
- how portable is end iterator decrement?
- Can std::begin work with array parameters and if so, how?
- Checking if an iterator is valid
- How does std::copy work with stream iterators
- Why does a push_back on an std::list change a reverse iterator initialized with rbegin?
- Can raw pointers be used instead of iterators with STL algorithms for containers with linear storage?
- What happens if you increment an iterator that is equal to the end iterator of an STL container
- What is the reason behind cbegin/cend?
- How to check that the passed Iterator is a random access iterator?
- Incrementing iterators: Is ++it more efficient than it++? [duplicate]
- How to increment an iterator by 2?
- Types of iterator : Output vs. Input vs. Forward vs. Random Access Iterator
- How can I copy one map into another using std::copy?