Reputation: 1451
What is the difference between using boost ptr containers and containers that contains smart pointers?
class A {}
// ptr containers:
boost::ptr_unordered_map<int, A> p;
// containers:
boost::unordered_map<int, boost::intrusive_ptr<A>> m;
Upvotes: 0
Views: 149
Reputation: 63755
boost::ptr_unordered_map
does not have the reference-counting overhead that would be incurred in a container of boost::shared_ptr<A>
It also does not require the additional A
object interface that boost::intrusive_ptr<A>
demands.
That makes it a good solution for managing heap-allocated objects that do not require reference counting of the contained objects.
Upvotes: 1