Hi, i created smart pointers class, which can be used as simple pointer or like pointer to pointer. Everything is works(i think) but there some confusion when trying to create pointer to pointer of type T.
here is some code
1 2 3
SmartPtr< int > a(3); //synonim for int * a = new int[3];
SmartPtr< SmartPtr<int> > a1(3); //synonim for int ** a1 = new int*[3];
a1[0].allocate(10); //a1[0] = new int[10];
so i need some idea about swapping SmartPtr< int * > p1;
to SmartPtr< SmartPtr<int> > p1;
it's only because i want to do using of my SmartPtr class more understandable. Is it possible to do what i want, if yes, what c++ features i must use to do this.
SmartPtr is smart pointer class which deletes allocated memory itself.
The main problem is, when i want to create "pointer to pointer to int" using SmartPtr class, the syntacs looks very confusion, like this SmartPtr< SmartPtr <int> > p(10);
so, i want to do something which will be more understandable, for example SmartPtr< int* > p(10);
so how i can do this?
It appears from the usage above that OP is creating a smart pointer to an array, which cannot be done
using boost::shared_ptr, however there does exist boost::shared_array for this purpose.