I am using boost::scoped_ptr
in the code which I would like to replace with std::unique_ptr
. I would like to know if there are any disadvantages in moving to std::unique_ptr
. Boost is portable across platforms and compilers. But I am not sure if C++11 supported by all compilers such as MSVC. I know GCC and Clang support C++11 pretty well.
I've already read the SO question “intrusive_ptr
in C++11” whose short answer is “No”. So If anyone had experience in using both, please share your comments and thoughts
Mgetz has generously provided the information that all recent VS implementations supply unique_ptr
.
I recommend that you replace boost::scoped_ptr<T>
with const std::unique_ptr<T>
. The reason for the const
is that this most closely models boost::scoped_ptr<T>
which is not "movable." However I believe boost::scoped_ptr<T>
does support swapping. So if you are using that, the compiler will complain everywhere you try to swap a const std::unique_ptr<T>
and you can then mark those instances as non-const
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With