在读取timdays answer到this question之后,我对boost::ptr_container
和std::vector<shared_ptr>
之间的区别感到好奇。我的印象是a boost::ptr_container
had ownership over the pointers given to it,一经发布,就会调用它所包含的所有指针的析构函数,而不管其他对其居民的引用如何。这与std::vector<shared_ptr>
的目的是相反的,如果引用计数为0,它只会释放指针本身?boost :: ptr_container和std :: vector <shared_ptr>
如果是这样的话(我认为它没有),为什么会连Boost文档例如compare the two就好像他们是在类似的用途,以及为什么会timday的回答提出了boost::ptr_container
当它的目的很不同的std::vector<shared_ptr>
。