Original Post
[font="Helv"][font="Helv"]I've got a function which creates and builds a dynamic array, then returns a pointer to it. Obviously this is going to need to be deleted somewhere down the line, but by the time it's no longer needed it's already been passed into and returned from two functions and so am I correct in thinking delete[] won't work, as by this point it's just seen as an ordinary pointer, not an array?
If this is the case, what's the best way of deleting the memory? I know the size of the array, so I could loop through it and just call delete on every item. Is there a smart-pointer that can be used with arrays which will delete it for me?
Holding a smart pointer to a std::vector won't really work due to the way the array is created in the first place. Unless there's a way of creating a vector quickly from a large array without having to loop through the whole array adding each element individually.
[/font][/font]
If this is the case, what's the best way of deleting the memory? I know the size of the array, so I could loop through it and just call delete on every item. Is there a smart-pointer that can be used with arrays which will delete it for me?
Holding a smart pointer to a std::vector won't really work due to the way the array is created in the first place. Unless there's a way of creating a vector quickly from a large array without having to loop through the whole array adding each element individually.
[/font][/font]