Boost logo

Boost :

From: Neal D. Becker (nbecker_at_[hidden])
Date: 2004-02-02 11:58:41

David Abrahams wrote:

> "Neal D. Becker" <nbecker_at_[hidden]> writes:
>> I have some legacy C code that returns a pointer:
>> fftw_plan fftw_create_plan(int n, fftw_direction dir, int flags);
>> where fftw_plan is a pointer.
>> Can I use shared_pointer to wrap it? I guess the issue is that
>> eventually delete will be called on this pointer, but it wasn't allocated
>> with new. Is this a problem?
> Custom deleters are your friend. See the shared_ptr docs for more
> info.

Thanks! Just what I needed:

boost::shared_ptr<fftw_plan_struct> plan;
plan (fftw_create_plan (_size, dir, flags), &fftw_destroy_plan)

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