I\'m wondering why in many template algorithms in the STL the arguments are not passed by reference but rather by value. Here is an example from the
One thing that comes to my mind and which is against the const
ness in the reference: the iterators need to be modified when using them.
Another implementation detail may be that iterators are really just implemented as pointers. So are references in most cases. If you pass the pointer by value, you copy it once but dereference it only when needed. If, however, the iterator-pointer itself is passed by a reference-pointer, then that has to be dereferenced first, just in order to get to the iterator, and that must be done each time the iterator is accessed. That is superfluous.