Raymond
Raymond

Reputation: 957

What is unique_ptr replacement for "visual studio 2008", no 3-rd libraries (eg. boost)

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....

Upvotes: 3

Views: 1840

Answers (1)

Arne Mertz
Arne Mertz

Reputation: 24576

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?

Upvotes: 3

Related Questions