Skip to content

New lambda implementation#745

Merged
andreasfertig merged 1 commit into
mainfrom
lambdas
Jun 10, 2026
Merged

New lambda implementation#745
andreasfertig merged 1 commit into
mainfrom
lambdas

Conversation

@andreasfertig

Copy link
Copy Markdown
Owner

The prior version requires not only a lot more code but was showing constructors of lambdas. Technically this was incorrect, because the standard requires direct initialization of all captures.

The new implementation swallows the pill making the caputures public and by that get the aggregate behavior.

GCC does something similiar in its implementation. They create an aggregate first and later switch it to a class:

https://github.com/gcc-mirror/gcc/blob/62a80185db84f20f3efb05c81598bffa95bcd63d/gcc/cp/lambda.cc#L121

The prior version requires not only a lot more code but was showing
constructors of lambdas. Technically this was incorrect, because the
standard requires direct initialization of all captures.

The new implementation swallows the pill making the caputures public and
by that get the aggregate behavior.

GCC does something similiar in its implementation. They create an
aggregate first and later switch it to a class:

https://github.com/gcc-mirror/gcc/blob/62a80185db84f20f3efb05c81598bffa95bcd63d/gcc/cp/lambda.cc#L121
@andreasfertig andreasfertig merged commit 37b1b1f into main Jun 10, 2026
24 checks passed
@andreasfertig andreasfertig deleted the lambdas branch June 10, 2026 09:12
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

Successfully merging this pull request may close these issues.

1 participant