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

Make implicit capture explicit for C++20 #1669

Merged
merged 5 commits into from
May 9, 2020

Conversation

daixtrose
Copy link
Contributor

I agree that my contributions are licensed under the {fmt} license, and agree to future changes to the licensing.

@vitaut
Copy link
Contributor

vitaut commented May 7, 2020

Thanks for the PR. There are some CI build failures: https://travis-ci.org/github/fmtlib/fmt/jobs/684199343

@daixtrose
Copy link
Contributor Author

daixtrose commented May 7, 2020

OK, it seems that mitigating the warning for a C++20 compiler is mutually exclusive to a C++14 compiler. Are you generally OK with the MACRO solution?

Looks like CI is passing

@daixtrose daixtrose changed the title Make implicit capture explicit Make implicit capture explicit für C++20 May 7, 2020
@daixtrose daixtrose changed the title Make implicit capture explicit für C++20 Make implicit capture explicit for C++20 May 7, 2020
@vitaut
Copy link
Contributor

vitaut commented May 7, 2020

Are you generally OK with the MACRO solution?

Sure but I suggest renaming FMT_CAPTURE_OF_THIS to FMT_CAPTURE_THIS.

@vitaut
Copy link
Contributor

vitaut commented May 8, 2020

Another option is to change = to explicit capture - it might be slightly better than a macro.

@daixtrose
Copy link
Contributor Author

Another option is to change = to explicit capture - it might be slightly better than a macro.

I am not sure how to do this such that it is portable since C++14 compilers reject any mention of this as error.

I suggest renaming FMT_CAPTURE_OF_THIS to FMT_CAPTURE_THIS.

ACK. Done.

@timsong-cpp
Copy link
Contributor

[this, num_digits]. I think that's the only thing you need to capture in all cases?

@vitaut
Copy link
Contributor

vitaut commented May 8, 2020

I am not sure how to do this such that it is portable since C++14 compilers reject any mention of this as error.

This seems to work (https://godbolt.org/z/jy-YYn):

struct S {
  void f() {
    int i;
    auto g = [i, this]() {};
    g();
  }
};

@daixtrose
Copy link
Contributor Author

Ok, I will give it a try.

@daixtrose
Copy link
Contributor Author

@vitaut explicit capture done. Now go fix your CI 🔂

@vitaut
Copy link
Contributor

vitaut commented May 9, 2020

Thanks! Looks like a transient failure, I restarted the job.

@vitaut vitaut merged commit 73e335e into fmtlib:master May 9, 2020
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.

Implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20
3 participants