|
Boost : |
From: axter (boost_at_[hidden])
Date: 2005-12-26 17:17:35
http://www.boost.org/libs/ptr_container/doc/reference.html
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.
http://www.boost.org/libs/ptr_container/doc/reference.html
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
class.
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:
http://code.axter.com/cow_ptr.h
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk