Why can a map of vector::iterator to int be defined but a map of list::iterator to int cannot?
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;
int main()
{
int ia[] = {1,2,3,4,5,6,7,8,9,0};
vector<int> v(begin(ia), end(ia));
auto it1 = find(begin(v), end(v), 4);
map< vector<int>::const_iterator, int > m1;
m1.insert(map<vector<int>::const_iterator, int>::value_type(it1,*it1));
list<int> l(begin(ia), end(ia));
auto it2 = find(begin(l), end(l),5);
map< list<int>::const_iterator, int> m2;
m2.insert(map<list<int>::const_iterator, int>::value_type(it2,*it2)); //doesn't compile
}
Error 1 error C2678: binary '<' : no operator found which takes a left-hand operand of type 'const std::_List_const_iterator<_Mylist>' (or there is no acceptable conversion)
m2.insertline, or the declaration of m2? - Uselessinsertline, since until then, the compiler doesn't instantiate any code that needs the comparison. - jpalecek