Input.begin() returns an iterator instead of a const_iterator , and your second argument is const_iterator , so the two arguments are basically of a different type. You can use cbegin() if you have access to the features of C ++ 11.
The second way to do this: Each iterator is converted to const_iterator by assignment
std::vector<int> myVector(100); std::vector<int>::iterator it = myVector.begin(); std::vector<int>::const_iterator cit = it;
If you need to send things to a function call, you can use magic magic:
std::distance( ((const Container*)&Input)->begin(), itTarget );
If Input is const, the compiler is forced to use the const version of begin (), which returns const_iterator.
source share