Fix implicit lambda capture of this in C++20
Implicit captures of this using [=] is deprecated in C++20. From the Book Nicolai Josuttis "The complete Guide for C++ 20" the correct new ways are:
- [=] -> [=,this] //Capturing this by reference
- [=,...] -> [=,this,...] //Capturing this by reference
However, [=,this]
is not allowed in C++17 so an alternative is to
- explicitly capture all variables by value if possible
- add a version check.
Edited by Timo Koch