-
-
Notifications
You must be signed in to change notification settings - Fork 245
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
non-mutable lambdas don't show members as const #189
Comments
It generates this:
Shouldn't the anonymous lambda be defined like this instead?
|
Hello @matkatmusic, thank you for raising that point. First of all, I'm not a 100% sure about it myself. Here is my view. The members don't need to be Now for lambda have a look at a reduced and modified version of your code: https://godbolt.org/z/NfTBVM. The What does the Standard say? Nothing about that a member must be All that said, I know that people often say/think that the members of a lambda are const in case of a non-mutable lambda. I also think I once saw a godbolt link proofing that, but I can't remember. Feel free to point me to a different direction. Andreas |
Capture-by-reference can call non-const member functions. you didn't share a godbolt link. I'm going off of what is stated here: https://en.cppreference.com/w/cpp/language/lambda
Is making an object |
Ok, my fault. The standard says that the |
True and it can also modify capture by reference variables.
I don't think that is true. Your own example from above calls a
I updated my earlier comment with the godbolt link.
Yes, but that is true for all classes not just lambdas. |
see my comment about the |
the generated lambda doesn't mark the private member in the anonymous body as
const Data d;
, which is should.The text was updated successfully, but these errors were encountered: