#include <cstdlib>   // for EXIT_SUCCESS

#include <iostream>  // for std::cout, std::endl

#include <memory>    // for std::shared_ptr, std::weak_ptr



using std::shared_ptr;

using std::weak_ptr;



int main(int argc, char **argv) {

  weak_ptr<int> w;



  {

    shared_ptr<int> x;

    {

      shared_ptr<int> y(new int(10));

      w = y;

      x = w.lock();

      std::cout << *x << std::endl;

    }

    std::cout << *x << std::endl;

  }

  shared_ptr<int> a = w.lock();

  std::cout << a << std::endl;



  return EXIT_SUCCESS;

}