Boost logo

Boost :

From: Ben Young (ben.young_at_[hidden])
Date: 2003-03-31 05:35:39


Hi,

I was wondering whether anyone had thought about adding a rebind nested
template class to the boost ptrs, similar to those used by allocators.
A situation has recently occurred where I need to get a ptr to a derived
class from a pre to a base class, where the ptr to the base class is used
a typedef e.g

struct Base {};

typedef boost::shared_ptr<Base> BasePtr;

void func(const BasePtr& base)
{

}

struct Derived : public Base {};

typedef boost::shared_ptr<Derived> DerivedPtr;
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
        Don't want to have to do this

func(DerivedPtr(new Derived)) ....... etc

The reason I dont want to have to do the second typedef is that we have a
number of smart pointer classes of our own, and the type of the BasePtr
should be an implementation detail. If boost::shared_ptr had a rebind,
then we could add it to our own classes as well, and the actual wrapper
used would become an implementation detail

Cheers

Ben Young


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk