Sigh: there is a level of hacking created to hide the fact that conceptually what you want to do cannot be done automatically in C ++ because it does not understand variance. Some other languages (including Ocaml) do.
If you have a functor (a template class for C ++ programmers), the question arises as to how it and various functions behave with changing a parameter, for example, converting from T to T const. What you really want is:
List<T> --> List<T const>
In other words, you want the List functor to be covariant. But no, it’s not .. so in fact the List template is not a functor at all, because functors must preserve the structure and the transformation is not reflected as necessary. In turn, this means that either C ++ templates are violated OR the concept of const is violated, because a type system that does not support parametric polymorphism is violated by the specification :)
Providing a "const_iterator" does not solve this problem, it just breaks the gap. Where is the mutable and const_volatile version? What about double directions?
If you do not understand double links: consider a tree of vectors from T, which are two patterns:
Tree<Vector<T>>
The best solution here is to abandon const_iterator support. Just don’t worry. In any case, this is confused: what about the "const vector"? What is it? A vector that you cannot draw longer, but it still allows you to write elements?
The actual requirement is that the transforms commute, for example:
vector<T> const == vector<T const>
[or they are anticommuted if the transformation is inconsistent)
The fact that this does not happen shows that the vector is not functorial, in other words, the patterns cannot be effectively used for parametric polymorphism. If you really want your panties to be knotted, consider templates with function arguments and ask about the variance of the return type of the function and parameters and how this can affect the container. A good example is the creation of two functions, so they work in pairs. What if they are mutators, how does const work?