3

Is there something like unique_ptr<> in Visual Studio 2008?

Event Visual Studio only header is also OK.

I want this feature but do not want to use 3-rd party lib. Since I am writing sample/learning code.

If not, I will have to use raw pointer directly, for simplification. Although I feel uncomfortable....

Raymond
  • 885
  • 10
  • 28

1 Answers1

3

VS2008 does not support rvalue references and thus no move operations. unique_ptr behavior relies on those, so there can be no exact replacement in C++03. auto_ptr uses the copy-Ctor to do what should be done by the move-Ctor. You could use those, but I'd recommend against it, because the compiler can't help you find unwanted copies like he does with unique_ptr.

Also see here: unique_ptr boost equivalent?

Community
  • 1
  • 1
Arne Mertz
  • 24,171
  • 3
  • 51
  • 90