Skip to content
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

Capture lambda are missing the deleted copy assignment #413

Closed
Ignition opened this issue Aug 24, 2021 · 2 comments
Closed

Capture lambda are missing the deleted copy assignment #413

Ignition opened this issue Aug 24, 2021 · 2 comments

Comments

@Ignition
Copy link

I have no idea why the standard is this way....but it is.
Hence in cppinsights I would expect to see something like __lambda_xyz& operator=(__lambda_xyz const &) = delete; for lambdas that capture.

http://eel.is/c++draft/expr.prim.lambda#closure-13

@andreasfertig
Copy link
Owner

Hello @Ignition,

that is an interesting point.

First let's be sure we are on the same page. You referring to something like this (in C++ Insights)
:

int main()
{
  int a = 4;
  
  auto lamb = [a]{};
  decltype(lamb) lambCopy = lamb;
  // lamb = lambCopy;
}

The reason why you don't see the expected deleted assignment operator is simply because it is not there. Clang doesn't border creating implicit special members if they are not used. You can see this in the AST output at Godbolt. Once you start assigning the lambCopy to lamb, the assignment operator is used but then deleted, making the program ill-formed. As a result, you don't see any output in C++ Insights.

Andreas

@Ignition
Copy link
Author

Yes, we are on the same page.

Ah yeah...if C++ insight is relying on Clang AST generation I see why ATM it says nothing on this topic.

Thank you for responding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants