Why do I get the compile error no matching function for call to `f( __gnu_cxx::__normal_iterator > >)'
?
#include <vector>
template<typename T>
void f(const typename std::vector<T>::iterator &) {}
void g() {
std::vector<int> v;
f<int>(v.end()); // Compiles.
f(v.end()); // Doesn't compile, gcc 4.3 can't find any match.
}
Ultimately I want to write a function which takes only a vector iterator, and fails to compile (with a meaningful error) for anything else. So template<typename T>void f(const T&) {}
is not a good solution, because it compiles for other types as well.