Boost logo

Boost :

From: axter (boost_at_[hidden])
Date: 2005-12-26 17:17:35

I'm trying to use the boost::ptr_map class, and either I'm misunderstanding
it's usage or syntax.

I originally assumed that a ptr_map class is a map container of pointers
and/or container of abstract objects via pointers.

However, the example code in the following link, does not seem to be using
pointers at all.

Moreover, if I attempt to use an abstract pointer in either the first or
second type, I get compile errors.

I also tried creating a ptr_map to a base class with a normal virtual
function, but when I ran my test, I can see that it slices the derived

So exactly what is the ptr_map class for, and does anyone have example code
that will work with an abstract pointer?

I'm trying to compare using the boost pointer containers to using a clone
smart pointer. Which boost container would be able to give me
functionallity like the following:

 map<cow_ptr<Shape>, int> mShapeToInt;
 map<int, cow_ptr<Shape> > mIntToShape;

Where Shape is an abstract base class, and cow_ptr is the following:


Boost list run by bdawes at, gregod at, cpdaniel at, john at