Closed linh2931 closed 1 year ago
Sorry about that. I think it probably could be fixed with (leaving the structured binding):
app->post(appbase::priority::high, [pA = pA] () { pA.do_throw("throwing in pluginA"); });
Sorry about that. I think it probably could be fixed with (leaving the structured binding):
app->post(appbase::priority::high, [pA = pA] () { pA.do_throw("throwing in pluginA"); });
Clang does not allow that:
/Users/lh/work/appbase-main/tests/basic_test.cpp:271:40: error: 'pA' in capture list does not name a variable
app->post(appbase::priority::high, [pA] () { pA.do_throw("throwing in pluginA"); });
^
/Users/lh/work/appbase-main/tests/basic_test.cpp:271:49: error: reference to local binding 'pA' declared in enclosing function 'exception_in_exec::test_method'
app->post(appbase::priority::high, [pA] () { pA.do_throw("throwing in pluginA"); });
I had written [pA = pA]
. Does clang not allow it?
You'll get
/Users/lh/work/appbase-main/tests/basic_test.cpp:271:52: error: 'this' argument to member function 'do_throw' has type 'const pluginA', but function is not marked const
app->post(appbase::priority::high, [pA=pA] () { pA.do_throw("throwing in pluginA"); });
^~
/Users/lh/work/appbase-main/tests/basic_test.cpp:51:13: note: 'do_throw' declared here
void do_throw(std::string msg) { throw std::runtime_error(msg); }
OK, thanks for checking Lin! Again sorry I missed this!
Resolve https://github.com/AntelopeIO/leap/issues/703.
Structured bindings are not capturable by lamda. Use tie instead.
Before the fix: