#include <cstdlib>   // for EXIT_SUCCESS

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

using std::shared_ptr;
using std::vector;

int main(int argc, char** argv) {
  vector<shared_ptr<int> > vec;

  vec.push_back(shared_ptr<int>(new int(9)));
  vec.push_back(shared_ptr<int>(new int(5)));
  vec.push_back(shared_ptr<int>(new int(7)));

  // z is (a reference to) the (int pointed to by the shared_ptr
  // in vec[1])
  int &z = *vec[1];
  std::cout << "z is: " << z << std::endl;

  // removes the last element of the vector and deallocates it (7)
  vec.pop_back();

  return EXIT_SUCCESS;
}