this post was submitted on 23 Jun 2023
7 points (100.0% liked)
C++
1783 readers
1 users here now
The center for all discussion and news regarding C++.
Rules
- Respect instance rules.
- Don't be a jerk.
- Please keep all posts related to C++.
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Although it looks like a nice proposal, I don't think that it's really workable. The major issue is that an additional scope is introduced, contrary to how for-loops normally work.
Say you throw an exception in the loop-body, it may be a surprise if generator123 handles the exception and there is no indication in the code that your exception will go through another scope.
And I just looked at the proposal and the 3 suggestions how to deal with exceptions and none of the proposals are good. Even worse: the operator() would act differently through compiler magic and depending on context.
I guess the syntax has to change, it looks pretty right now, but I don't think it can stay that way.