Closed Jamaika1 closed 1 month ago
Explicit capture of this is only valid in C++20 and later. See the C++20 https://wg21.link/p0409r2 paper.
Explicit capture of this is only valid in C++20 and later. See the C++20 https://wg21.link/p0409r2 paper.
So there as is a new feature that is syntax incompatible with previous versions but not using it breaks the code as well? Great design philosophy/s.
@Jamaika1 our code is written using C++14 (set( CMAKE_CXX_STANDARD 14 )
), so your guard is guaranteed to be false, is thus unnecessary. I don't know why and how this is overwritten, but the fact that it is is your actual bug. Closing.
Explicit capture of this is only valid in C++20 and later. See the C++20 https://wg21.link/p0409r2 paper.
So there as is a new feature that is syntax incompatible with previous versions but not using it breaks the code as well? Great design philosophy/s.
Jakub's comment is a bit misleading.
There's a new feature that is only valid in C++20, i.e. [=, this]
.
But the previous behaviour of [=]
can just be replaced with [this]
in your code, because the only thing you're trying to capture is this
. That is perfectly valid in all versions of C++ from C++11 upwards.
So the correct fix here is to replace [=]
with [this]
and not have any #if
conditional code.
(and it was only a warning anyway, so the old syntax is still compatible in C++20)
@jwakely : Thank you very much for the clarification. I didn't know [=, this]
was disallowed pre c++17. I thought it was just redundant.