I'm trying to get the index of an iterator of a list, I've read this stackoverflow question and tried the following code:
std::list<int> v;
std::list<int>::iterator iter = v.insert(v.begin(), 1);
int i = iter - v.begin();
Surprisingly it doesn't work, I got an error.
error: invalid operands to binary expression
What's the problem? How to make it work?