Should I switch from using boost::shared_ptr to std::shared_ptr?

后端 未结 8 1811
一生所求
一生所求 2020-12-23 02:06

I would like to enable support for C++0x in GCC with -std=c++0x. I don\'t absolutely necessarily need any of the currently supported C++11 features in GCC 4.5 (

8条回答
  •  独厮守ぢ
    2020-12-23 03:00

    Aside from implementation consistency, boost::shared_ptr currently retains at least two niche advantages over std::shared_ptr:

    • The availability of boost::make_shared_noinit. It's particularly useful in conjunction with arrays, avoiding both the cost of zero-initialization and the overhead of separate allocation. (FWIW, it's also a proposed addition to the standard.)
    • Boost.Python makes special use of boost::shared_ptr's support for type-erased custom deleters, but doesn't yet do the same for std::shared_ptr.

提交回复
热议问题