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

cpp-20 lambda fix #256

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

cpp-20 lambda fix #256

wants to merge 1 commit into from

Conversation

seba2390
Copy link

Ensuring cpp-20 compiler standard compatibility by fixing reference in lambda function.

@PaulXiCao
Copy link
Contributor

Just for reference: see here for the documentation of lambda-captures: cppreference.com

@@ -1096,7 +1096,7 @@ struct BooleanExpr

void update() { val = expr(); }

auto operator! () const { return BooleanExpr([=]() { return !(expr()); }); }
auto operator! () const { return BooleanExpr([=, this]() { return !(expr()); }); }
Copy link
Contributor

@PaulXiCao PaulXiCao Dec 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is enough to capture this, i.e. [this](){ return ...}. For C++17 it is even not allowed to specify both. It is a bit hidden but specified on cppreference.

@PaulXiCao
Copy link
Contributor

If C++20 is a goal then we might should search for similar things. A simple regex might be enough at first or parse the code base with libclang?

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.

None yet

2 participants