structured binding does not define variables, and the implicit
capture-by-copy `=` does not help in this case, we have to define a
capture with an initializer to create a *variable* enclosed by
the closure explicitly.
this address the error like:
src/crimson/os/seastore/segment_cleaner.cc:315:5: error: reference to local binding 'addr' declared in enclosing lambda expression
addr);
^
Signed-off-by: Kefu Chai <kchai@redhat.com>
addr,
info.addr,
info.len
- ).safe_then([=, &t](CachedExtentRef ext) {
+ ).safe_then([addr=addr, &t, this](CachedExtentRef ext) {
if (!ext) {
logger().debug(
"SegmentCleaner::do_gc: addr {} dead, skipping",
t,
ext);
});
- }).safe_then([=, &t] {
+ }).safe_then([next=next, &t, this] {
auto old_pos = std::exchange(gc_current_pos, next);
if (gc_current_pos == P_ADDR_NULL) {
t.mark_segment_to_release(old_pos.segment);