Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • @David, because there's no point, since you know you don't own the elements of the array (you're just traversing it) and coordinating with whoever owns the array would be very complicated. Besides, it might be a stack-allocated array requiring no memory management at all. Commented Apr 7, 2010 at 14:31
  • I believe that smart_ptr allows you to overload the function which cleans up the memory. Hence, it's quite concievable that a memory pool would work just fine with a smart_ptr as long as your clean-up function was properly coordinated with your creation function. Commented Apr 7, 2010 at 14:54
  • I find 1 and 3 straw men. On 1, most smart pointers have some sort of get, so you can still pass the contained pointer. And 3 isn't even a situation that matters. That's like saying "4. An integer. 5. A float." etc for each type. It just doesn't apply. And 2 is solved with a weak pointer. Commented Apr 7, 2010 at 15:03
  • @Marcelo: The question was things you can't do with smart pointers, not situations where smart pointers aren't useful. Commented Apr 7, 2010 at 15:26
  • @David, @GMan: in which case saying "there is nothing you can do with a raw pointer that you can't do with a smart pointer, because a smart pointer can return a raw pointer, and you can use that" rather misses the point IMO. Surely this is a question about what raw pointers are needed for, not a question about whether you can shove a smart pointer into some context where it doesn't help. I'm sure you can, but why would you? Commented Apr 7, 2010 at 16:08