Arithmetic on end() iterator
问题 Let A be a std::vector<double> , Is this well-defined? if(!A.empty()) std::vector<double>::iterator myBack = A.end() - 1; Is the end iterator only good for equalities and inequalities checks? Or I can perform some pointer arithmetic as long as I remain in the container? On my platform this code works. I'm wondering if this is portable. 回答1: It is perfectly valid as vector::iterator is a random access iterator. You can perform arithmetic operations on it and it is not platform dependent. std: