You can use std::distance
. For example:
auto index = std::distance(v.begin(), iter);
Quoting:
If it is a random-access iterator, the function uses operator- to calculate this. Otherwise, the function uses the increase operator (operator++) repeatedly.