Hacker News new | past | comments | ask | show | jobs | submit login

An iterator is a class. It can contain any private data you desire and mutate in any wonderful and/or stupid ways you desire.

How it decides to compare equal to the .end() instance is also your call. Your example is not a compliant iterator (as in, wouldn't work in a range-based for loop) - yet the same behaviour would be achievable through your own operator++() and operator bool(),




I agree, but I feel it is a little sad that such a powerful programming concept as an iterator is hard to implement in C++ if you want to make full use of it. Other program languages have made better choices with respect to this and allow you to write cleaner, shorter code.


Why not just use those two operators instead of more and next?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: