-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Allow writing mutators with lambdas #8877
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
base: main
Are you sure you want to change the base?
Conversation
|
If we like this direction, we can make a version for visitors, too. |
|
We can also consider adding |
I went ahead and did this -- clang-format decides to add a line, but I prefer how the functional form reads. |
This follows the implementation of
std::visit, using a struct to accumulate function overloads and then dispatching to the correct one at compile time (usingstd::is_invocable_v). The result is the ability to define mutators that capture local state. I convert a few visitors in the codebase as a means to achieve some test coverage.For example, this is the code for
expand_exprinside StorageFlattening.cpp:We need the pointer to the mutator as the second argument.