0

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;
Drew Dormann
  • 59,987
  • 13
  • 123
  • 180
Zilberman Rafael
  • 1,341
  • 2
  • 14
  • 45
  • 3
    I'm rolling back the latest revision. If you have a new question, [ask a new question](http://stackoverflow.com/questions/ask). It's bad form here to edit a question to invalidate existing answers. – Drew Dormann Jul 25 '14 at 18:04

1 Answers1

1

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.

Drew Dormann
  • 59,987
  • 13
  • 123
  • 180