-
-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fold expression instantiation #336
Comments
Hello @korelkashri, all issues are important, at least to me. Thanks for reporting this one. The goal is to show correct code which compiles and yields the same result. However, showing "correct" code is not always possible. You are right, the outer parenthesis are missing. The reason is, that in the instantiation of the function template there are only expressions left like in this case
I'm not sure whether I'm missing something here, but in this case the output is correct, all braces are there. The In summary, the first part is slightly incorrect but yields to the correct result. It will stay that way, except somebody finds a clever way to detect that this was/is part of a fold expression. The second part is in my opinion correct. Andreas |
No, you are right, I showed the second example to show that the behavior is correct, it just doest show the outer parenthesis in case that they aren't require. |
A really important issue about fold expressions is the parenthesis. Now, it's not a bug, but a possibility for a wrong understanding of how does fold expression instantiation work. A simple example:
Will produce the following specialization:
Which is mostly right, at this particularly case- There should be an outer parenthesis, but they are meaningless here. But not in the following case:
For this one, the output will be:
Which is really nice, but also might fool some students.
Now, I'm not sure who you are targeting with this amazing tool, but I think it might be nice to consider adding the parenthesis, even when they are not fully necessary.
The text was updated successfully, but these errors were encountered: