How does overloading of const and non-const functions work?
c++, constants, function, overloading, stl
Solution
In the example you gave:
vector<int>::const_iterator it = myvector.begin();
if `myvector` isn't const the non-const version of `begin()` will be called and you will be relying on an implicit conversion from iterator to const_iterator.
Problem
The `STL` is full of definitions like this: ``` iterator begin (); const_iterator begin () const; ``` As return value does not participate in overloading resolution, the only difference here is the function being `const`. Is this part of the overloading mechanism? What is the compiler's algorithm for resolving a line like: ``` vector<int>::const_iterator it = myvector.begin(); ```