Difference between boost::shared_ptr and std::shared_ptr from the standard file

后端 未结 1 973
臣服心动
臣服心动 2020-12-29 03:40

I was wondering if there are any differences between the boost::shared_ptr and the std::shared_ptr found in the standard

相关标签:
1条回答
  • 2020-12-29 03:58

    std::shared_ptr is the C++0x form of tr1::shared_ptr, and boost's boost::shared_ptr should behave the same.

    However, std::shared_ptr, in an implementation that conforms to C++0x standard, should/might have more convenience behavior on the shared_ptr class, as described in the following links:

    • Differences between different flavours of shared_ptr

    • http://en.wikipedia.org/wiki/C%2B%2B0x#General-purpose_smart_pointers

    The shared_ptr is a reference-counted pointer that acts as much as possible like a regular C++ data pointer. The TR1 implementation lacked certain pointer features such as aliasing and pointer arithmetic, but the C++0x version will add these.

    • November 2010 Working Draft of C++0x

    Though from a quick cursory glance, I do not see operator+ and similar arithmetic operations on the shared_ptr type.

    0 讨论(0)
提交回复
热议问题