// Author: A.Voss@FH-Aachen.de
//
// http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Execute-Around_Pointer

#include <iostream>
#include <cstdlib>
#include <vector>
#include <memory>
using namespace std;

class VisualizableVector {
public:
	class proxy {
	public:
		proxy (vector<int> *v) : vect (v) {
			cout << "Before size is: " << vect->size () << endl;
		}
		vector<int> * operator-> () { return vect; }
		~proxy () {
			cout << "After size is: " << vect->size () << endl;
		}
	private:
		vector <int> * vect;
	};

	VisualizableVector(vector<int> *v) : vect(v) { }    
	proxy operator-> () { return proxy (vect); }
private:
	vector <int> * vect;
};

int main()
{
    cout << endl << "start" << endl;
    
	VisualizableVector vecc (new vector<int>);
	vecc->push_back (10); 
	vecc->push_back (20);

	// Aufgabe: Klasse als Template AspectPtr modellieren und mit 
	// 		    smart-ptr (shared_ptr) versehen
	// AspectPtr<vector<int>> a;
	// a->push_back(12);

    cout << "end" << endl << endl;
        
    return EXIT_SUCCESS;
}

