std::auto_ptr is broken in VC++ 8 (which is what we use at work). My main gripe with it is that it allows auto_ptr<T> x = new T();, which of course leads to horrible crashes, while being simple to do by mistake.

From an answer to another question here on stackoverflow:

Note that the implementation of std::auto_ptr in Visual Studio 2005 is horribly broken. http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=98871 http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=101842

I want to use

  • boost::scoped_ptr, for pointers that shouldn't pass ownership.
  • boost::shared_ptr, for pointers in containers and elsewhere where they are required.
  • std::auto_ptr, for pointers that should/can pass ownership.

But since std::auto_ptr is broken for me, I wonder what would be the best approach:

  • Replace std::auto_ptr with something from the net. Like this this one from Rani Sharoni (haven't tried it yet).
  • Use boost::shared_ptr instead. Will of course work, although there will be some minor overhead that I don't care about. But I want to use auto_ptr to signal the intent of the pointer. (See this answer for a vo
Edit
Report