C++ Smart Pointer performance

前端 未结 6 1728
北荒
北荒 2021-02-07 05:24

How much do using smart pointers, particularly boost::shared_ptr cost more compared to bare pointers in terms of time and memory? Is using bare pointers better for performance i

6条回答
  •  渐次进展
    2021-02-07 06:01

    There's an often overlooked halfway-house between a "manually" managed std::vector (ie raw pointers) and a std::vector >, in the form of the boost::ptr_container classes.

    These combine the performance of a raw pointer container with the convenience of a container of smart pointers (ie they provide the functionality people would like STL containers of std::auto_ptr to provide, if that worked).

提交回复
热议问题