std::list<CPoint>::iterator iter= vertices.end();
CPoint point = *(iter+1);
In such cases I’ve tried to assign to variables the value of (iter-1) or (iter+1). Why doesn’t it work? whereas iter++ or iter-- works.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Simply, these operations are not part of the
iteratordefinition. You can use thestd::advance()function for that.Obviously, the
operator+(int)could be overriden to do that, just asoperator++()is, but probably it is not, because this operation is not guaranteed to be of constant complexity, and a syntax like(iter + n)could suggest otherwise.From
advance: