Using smart pointers with arrays



How can I create a smart pointer to an array of double?. I want to convert this expression :

double* darr = new double[N]; // Notice the square brackets

using smart pointer auto_ptr

the following instruction doesn't work:

auto_ptr<double[]> darrp(new double[N]);

Also how to get the values of the array using the smart pointer?.

Thanks

Younès
The auto_ptr has been deprecated (set to "do not use any more" status).

unique_ptr can be used with arrays:
http://www.cplusplus.com/reference/memory/unique_ptr/operator[]/
Topic archived. No new replies allowed.