0

Possible Duplicate:
Which kind of pointer do I use when?

I read that std::auto_ptr is obsolete, so you must use std::tr1::shared_ptr instead. As I read difference is std::tr1::shared_ptr have reference counting, while std::auto_ptr haven't, so copying or assigning makes the resource changing its owner, with the source giving the ownership to the destination. Is it the only difference?

Community
  • 1
  • 1
Alecs
  • 2,256
  • 8
  • 32
  • 45

1 Answers1

2

The smart pointer that closest matches the single ownership semantics of auto_ptr is std::unique_ptr. This should be used preferentially over std::shared_ptr, if available. See here.

juanchopanza
  • 223,364
  • 34
  • 402
  • 480