Q: I've tried "if (pointList.back())" instead, but that gives me a "no operator matches these operands" error.
The problem with that approach is you need to compare the iterator against the last element, and not just check if the last element in the list is zero or not.
The better approach would be is to check if the iterator points to the "end -1" as follows:
else if (next(i) == pointList.end())
Note that std::next
was only introduced in C++11, so without support for that, you would need to create the semantics yourself or just use boost::next
.