Differences between different flavours of shared_ptr
Asked Answered
S

1

17

Are there any differences between boost::shared_ptr, std::tr1::shared_ptr and the upcoming (in C++0x) std::shared_ptr?

Will porting from one to another have any overhead or are they basically the same?

Sister answered 6/7, 2009 at 12:53 Comment(1)
Not directly related to your question, but c++0x's unique_ptr will be an improvement on scoped_ptr where you can do things like this: std::unique_ptr<int[]> p(new int[10]);Prying
S
29

According to the Boost website, the boost::shared_ptr...

...conforms to the TR1 specification, with the only exception that it resides in namespace boost instead of std::tr1.

According to the Wikipedia C++0x page

The TR1 implementation lacked certain pointer features such as aliasing and pointer arithmetic, but the C++0x version will add these.

If your code works with the TR1/Boost version, it should work with the C++0x version (but not necessarily vice versa).

Saxhorn answered 6/7, 2009 at 17:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.