You need to use standard function std::distance
index = std::distance( myvector.begin(), it );
if ( index < myvector.size() )
{
// do something with the vector element with that index
}
Try always to use std::distance even with random access iterators. This function is available in the new and old C++ Standards.