Fix warning with lambda captuer mplicit capture of 'this' with a capture default of '=' for Gui01 (c++20 and above)#291
Conversation
|
OK, I see where is the problem. When switch backed to c++17: It looks like it was in only one place. For the rest I don't use [=, this], instead I use more specific targeting. The only places that needed to be changed is AsyncWork::Impl. Now it is: |
@klugier |
|
At this point: Let us wait 2 years, then switch to C++20. It is not only uppsrc, but also client apps... |
|
We should adopt this change sooner rather than later. The main problem is that manually switching to a newer standard pollutes compilation logs with warnings. This change won't hurt compatibility with C++17, as the updated code is perfectly valid for that standard. I don't propose a single, massive change. My plan is to start with several packages from uppsrc and submit the fixes in a few pull requests. Ultimately, all the code within our official distribution will be updated. For client-side code, we'll fix what's on our end. It will be the client's decision whether to fix their own code or tolerate the compilation warnings. In this scenario, we'll be clear that we aren't responsible for these warnings. |
Well, for a starter, I'll see if I can get the SSH package comply with the C++20 rule without breaking anything. I think it would be trivial because all lambda calls are internal and they don't do any magic. |
It looks like fixing the issue with deprecation of capturing this with [=] won't be that difficult. I just wanted to start the whole process. I fixed this warning for Gui01 tutorail and associated pacakges, so right now while compiling Gui01 example with std=c++20 and above there shouldn't be following warning:
C:\Prototable\upp\git\uppsrc\CtrlLib\CtrlUtil.cpp (410): warning: implicit capture of 'this' with a capture default of '=' is deprecated [-Wdeprecated-this-capture]Also, I think the code is batter, because we are capturing variables we don't want to. I suggest making this kind of changes in chunks. At some point of time, we will eliminate all warnings of that kind.
I would like to add that maybe we might do not like the new syntax and it is longer to what we had in the past. But, the overall solution is batter, especially when you capture [this] instead of [=]. In this case the local variables are not copied. In the end we shouldn't consider silencing this warning. Also, at some point it might be a compilation error, so we will be forced to fix it.
The next step would be to fix all Gui* tutorials. After that we can jump to other places like ide.