I'm running VC++ 2005 so std::unique_ptr
is not available AFAIK. I use some library functions (black box) which effectively do return new T[n]
and I want to wrap the result in some object which will mean I don't have to delete them in my destructor.
Does anything exist in the standard libraries circa VC++ 2008? If not, would the boost version of unique_ptr work perfectly as in this answer?
To clarify some confusion in the comments, the library function returns a raw pointer to a dynamically allocated array and I don't have access to change that... I need to take that pointer and wrap it in an object which automatically calls delete []
when the object goes out of scope.