conservation-laws / ryujin

High-performance high-order finite element solver for hyperbolic conservation equations
https://conservation-laws.org
Other
103 stars 25 forks source link

C++20 no longer captures 'this' implicitly in lambda functions. #73

Closed bangerth closed 4 months ago

tamiko commented 4 months ago

@bangerth Would you mind to fix indentation?

-          psi = [=,this](double x, double v) {
+          psi = [=, this](double x, double v) {
-          find_velocity = [=,this](double x) {
+          find_velocity = [=, this](double x) {
tamiko commented 4 months ago
/__w/ryujin/ryujin/source/euler/initial_state_becker_solution.h:116:20: error: explicit capture of 'this' with a capture default of '=' is a C++20 extension [-Werror,-Wc++20-extensions]
          psi = [=,this](double x, double v) {

@bangerth In CMakeLists.txt would you mind to simply bump CMAKE_CXX_STANDARD to 20?

bangerth commented 4 months ago

I fixed the indentation, but the other issue falls into the "ugh" category. Is the compiler saying that [=,this] captures the object, not the pointer by-value? Would [this,=] be the right way to write this?

tamiko commented 4 months ago

@bangerth I think you're right, this is just the order. [this, =] should be the correct one.

bangerth commented 4 months ago

OK, so done.

tamiko commented 4 months ago

@bangerth That didn't fix it. We could work around the issue by explicitly capturing what is used in these two functions, or by disabling the deprecation warning.

But honestly, let's just switch to C++20. yolo

I have pushed a commit to your branch that does just that.