Yes, the C ++ iterator method is allowed and, as you indicated, can throw in certain circumstances.
The only class of functions in C ++ that cannot get out is the destructor. Indeed, this is simply by agreement (because it makes certain operations almost impossible for proper operation). Destructors can quit, it's very easy to let them do it.
Separate functions can be marked throw()to prevent them from tossing.
source
share