fork download
  1. #include <iostream>
  2. #include <memory>
  3. using namespace std;
  4.  
  5. int main() {
  6. auto ptr = std::make_unique<int>();
  7. auto c = std::shared_ptr<int>(ptr.release());
  8. auto lambda = [=] {
  9. std::cout << *c;
  10. };
  11. std::function<void()> f = std::move(lambda);
  12. f();
  13. return 0;
  14. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
Standard output is empty