$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Douglas Gregor (gregod_at_[hidden])
Date: 2003-08-28 18:22:36
On Wednesday 27 August 2003 10:11 am, Thorsten Ottosen wrote:
> shared_ptr<> can hold incomplete types. Aparently the trick
> is to hold a pointer to a destructor function.
>
> However, from reading the code, it is quite hard to understand completely.
>
> Does anyone know some resource that describes the technique
> (or maybe someone could explain it to me)?
When you put a new T* into shared_ptr<T>, T must be a complete type, so that
that point shared_ptr<T> generates an appropriate deleter for type T because
it _knows_ the destructor has to be there, and saves a pointer to that
deleter function. In other translation units, shared_ptr<T> can use the
deleter by calling through the function pointer without ever instantiating a
deleter.
Doug