Boost logo

Boost :

From: Daniel Wallin (dalwan01_at_[hidden])
Date: 2004-01-02 07:23:33


David B. Held wrote:
> "Daniel Wallin" <dalwan01_at_[hidden]> wrote in message
> news:3FF4834A.9060608_at_student.umu.se...
>
>>[...]
>>Very useful for pimpl classes and for storing polymorphic objects.
>>
>> http://www.cs.umu.se/~ens01dwn/value_ptr.hpp
>
>
> Looks like it could be spelled: smart_ptr<T, deep_copy>, if
> someone would ever finish that thing. ;)

Really? I'm assuming you mean that it could be spelled that way if
deep_copy was rewritten

(I'm looking at:
   boost-sandbox/boost/policy_ptr/latest/smart_ptr.hpp)

to support capturing of the pointee type at the time of construction.
But even then smart_ptr<> is lacking the:

   const_pointer_type operator->() const
   const_reference_type operator*() const
   .. and maybe a templated reset().

needed to propagate constness. But then, const_pointer_type and
const_reference_type comes from the storage policy so we'd need one of
those too. And the storage policy also needs to capture the type to
properly delete the pointee.

So we end up with;

   smart_ptr<
       T
     , deep_copy
     , const_propagating_storage
>

Unfortunatly both the storage and ownership policies need to capture the
type of the pointee, meaning they both need to store a function pointer.
So we'd end up with a smart pointer that is much larger than needed.

Am I wrong?

-- 
Daniel Wallin

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