Boost logo

Boost :

From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2006-03-10 15:40:42


> Another option is here: http://www.kangaroologic.com/move_ptr/
>
> static_move_ptr is roughly a C++03 emulation of the proposed unique_ptr.

This static_move_ptr has an advantage I tried to emulate with
boost::shmem::scoped_ptr (in the future
boost::interprocess::scoped_ptr), which also has a template argument for
the deleter (a must to free a shared memory portion allocated with
buffer) and a "release" member.

This allows user defined rollback functions using the deleter. You
surely can do this with shared_ptr, but sometimes allocating the
reference count is an overkill.

I would suggest adding a templatized deleter for scoped_ptr (we don't
always need "operator delete" to erase a pointer) or creating a
templatized basic_scoped_ptr. The "release" member is in my opinion a
good addition to allow rollback semantics (although implementing
rollback functors as scoped_ptr deleters is a bit hard, even with
bind/lambda). We can propose a rollback_ptr for this if we don't want to
change scoped_ptr, although Andrei Alexandrescu's suggestion
(on_block_xxx) would be optimal.

Regards,

Ion


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