The problem is that the compiler internally doesn't actually try to match "f(list<int>::iterator)", but actually "f(list_iterator<int>)", or whatever type list<int>::iterator actually is. It isn't able to figure out that this should match with list<T>::iterator.
You would be better just writing the function as: template<T> int f(T& a) { } and then using iterator_traits to find out information about T. Yes this means people could pass the "wrong object" to the function, but that is unfortunatly unavoidable. If you really want to stop wrong objects being passed, you could investigate enable_if, and do something like (warning, this code will certainly not compile, but should give you the vague idea) template<T> int f(T& a, enable_if<is_same<T, list<iterator_traits<T>::value_type> >::value> = 0) { .. } But I really really would just trust people to pass the right things to the function. The other advantage of just allowing anything to be passed is your code probably isn't actually list-specific, just bidirectional iterator specific, so being more general is good. _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus