0

Is the following code safe?

void foo() {
  Object bar;
  callback_in_5_sec([&]() {
    print(bar);
  });
} // bar goes out of scope but is it being retained because it is captured?
eclipse
  • 2,831
  • 3
  • 26
  • 34
  • 3
    No, `bar` is destroyed once it gets out of scope of `foo`. – Jaa-c Aug 02 '18 at 09:20
  • You might want to have a look at [Move capture in lambda](https://stackoverflow.com/questions/8640393/move-capture-in-lambda). – George Aug 02 '18 at 09:23

0 Answers0