Boost logo

Boost :

From: David M. Jones (djones_at_[hidden])
Date: 2004-10-15 13:19:34

I ran into a situation (see my "smart list" post on the boost users group)
where I wanted to create a custom allocator whose pointer typedef is
boost::shared_ptr. In other words, the code would look something like:

template <typename T>
class my_allocator
        typedef boost::shared_ptr<T> pointer;

The problem with doing this is that boost::shared_ptr<T> does not have the
same "interface" as the equalivalent raw pointer type T*. (I use the term
interface in the generic programming/template sense; not in the object
oriented sense.) One example is that there is no operator= on
boost::shared_ptr that takes a raw pointer; instead reset() must be used.

Here are my questions:
(1) What advantage does this change of interface serve that makes it worth
breaking potential operations such as that above?
(2) Does anyone have ideas on how to get around this problem? I toyed with
the idea of writing a class that derives from boost::shared_ptr and has the
interface that I desire -- anybody have thoughts on this?

David M. Jones

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