#include <iostream>

#include "ToyPtr.h"

using std::cout;
using std::endl;
using std::ostream;

// Simple struct to illustrate "->" operator.
typedef struct Pt_st { int x = 1, y = 2; } Point;

ostream& operator<<(ostream& out, const Point& rhs) {
  return out << "(" << rhs.x << "," << rhs.y << ")";
}

int main(int argc, char** argv) {
  // Create a dumb pointer.
  Point* leak = new Point;

  // Create a "smart" pointer.  (OK, it's still pretty dumb.)
  ToyPtr<Point> notleak(new Point);
  ToyPtr<Point> test(nullptr);  // nothing bad happens when destructed!

  // Use them.
  cout << "     *leak: " << *leak << endl;
  cout << "   leak->x: " << leak->x << endl;
  cout << "  *notleak: " << *notleak << endl;
  cout << "notleak->x: " << notleak->x << endl;

  // Return, leaking "leak" but not "notleak".
  return EXIT_SUCCESS;
}